Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requests.exceptions.TooManyRedirects #25

Open
jarib opened this issue Apr 11, 2019 · 0 comments
Open

requests.exceptions.TooManyRedirects #25

jarib opened this issue Apr 11, 2019 · 0 comments

Comments

@jarib
Copy link

jarib commented Apr 11, 2019

Sometimes one of my feeds has a redirect bug and the script crashes:

Traceback (most recent call last):
  File "/usr/local/bin/trackthenews", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/trackthenews/core.py", line 420, in main
    articles = parse_feed(outlet, url, delicate, redirects)
  File "/usr/local/lib/python3.7/site-packages/trackthenews/core.py", line 188, in parse_feed
    article = Article(outlet, title, url, delicate, redirects)
  File "/usr/local/lib/python3.7/site-packages/trackthenews/core.py", line 43, in __init__
    self.canonicalize_url()
  File "/usr/local/lib/python3.7/site-packages/trackthenews/core.py", line 54, in canonicalize_url
    res = requests.head(self.url, allow_redirects=True, timeout=30)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 98, in head
    return request('head', url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 640, in send
    history = [resp for resp in gen] if allow_redirects else []
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 640, in <listcomp>
    history = [resp for resp in gen] if allow_redirects else []
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 140, in resolve_redirects
    raise TooManyRedirects('Exceeded %s redirects.' % self.max_redirects, response=resp)

It would be better if this error was reported but ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant