jackfrued / jackfrued/Python-100-Days

请教这句代码哪错了??

Open
#230 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
187k
Forks
55.8k
PR merge metrics
No merged PRs in 30d

Description

rt=requests.get("https://baike.baidu.com/item/Python/407313") #这句执行错误,没想明白为什么
Traceback (most recent call last):
File "<pyshell#173>", line 1, in
rt=requests.get("https://baike.baidu.com/item/Python/407313")
File "C:\Users\000\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\000\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\000\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\000\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 668, in send
history = [resp for resp in gen] if allow_redirects else []
File "C:\Users\000\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 668, in
history = [resp for resp in gen] if allow_redirects else []
File "C:\Users\000\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 165, in resolve_redirects
raise TooManyRedirects('Exceeded %s redirects.' % self.max_redirects, response=resp)
requests.exceptions.TooManyRedirects: Exceeded 30 redirects.
rt=requests.get("https://baike.sogou.com/v58828.htm?fromTitle=Python") #这一句可以执行,为什么上一句出错?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two requests shown in the issue and read the traceback through requests/api.py and requests/sessions.py, especially the redirect handling. The issue would need a confirmed project change or a documented explanation of why the Baidu URL redirects repeatedly while the Sogou URL succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.