akamhy / waybackpy

Wayback Machine API interface & a command-line tool
https://pypi.org/project/waybackpy/
MIT License
484 stars 33 forks source link

Exceeded 30 redirects. #178

Open Natkeeran opened 2 years ago

Natkeeran commented 2 years ago

Describe the bug

Running into the Exceeded 30 redirects when saving urls. I was using the same script before, did not encounter this type of issue. Leaving 15 seconds before each request, thus this is not making too many requests to IA. Often fails even when trying to save the first url.

2     user_agent = "Mozilla/5.0 (Windows NT 5.1; rv:40.0) Gecko/20100101 Firefox/40.0"
      3     save_api = WaybackMachineSaveAPI(save_url, user_agent)
----> 4     save_api.save()

~/.local/lib/python3.8/site-packages/waybackpy/save_api.py in save(self)
    208                 self.sleep(tries)
    209 
--> 210             self.get_save_request_headers()
    211             self.saved_archive = self.archive_url_parser()
    212 

~/.local/lib/python3.8/site-packages/waybackpy/save_api.py in get_save_request_headers(self)
     87         )
     88         session.mount("https://", HTTPAdapter(max_retries=retries))
---> 89         self.response = session.get(self.request_url, headers=self.request_headers)
     90         # requests.response.headers is requests.structures.CaseInsensitiveDict
     91         self.headers = self.response.headers

~/.local/lib/python3.8/site-packages/requests/sessions.py in get(self, url, **kwargs)
    540 
    541         kwargs.setdefault('allow_redirects', True)
--> 542         return self.request('GET', url, **kwargs)
    543 
    544     def options(self, url, **kwargs):

~/.local/lib/python3.8/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    527         }
    528         send_kwargs.update(settings)
--> 529         resp = self.send(prep, **send_kwargs)
    530 
    531         return resp

~/.local/lib/python3.8/site-packages/requests/sessions.py in send(self, request, **kwargs)
    665             # Redirect resolving generator.
    666             gen = self.resolve_redirects(r, request, **kwargs)
--> 667             history = [resp for resp in gen]
    668         else:
    669             history = []

~/.local/lib/python3.8/site-packages/requests/sessions.py in <listcomp>(.0)
    665             # Redirect resolving generator.
    666             gen = self.resolve_redirects(r, request, **kwargs)
--> 667             history = [resp for resp in gen]
    668         else:
    669             history = []

~/.local/lib/python3.8/site-packages/requests/sessions.py in resolve_redirects(self, resp, req, stream, timeout, verify, cert, proxies, yield_requests, **adapter_kwargs)
    164 
    165             if len(resp.history) >= self.max_redirects:
--> 166                 raise TooManyRedirects('Exceeded {} redirects.'.format(self.max_redirects), response=resp)
    167 
    168             # Release the connection back into the pool.

TooManyRedirects: Exceeded 30 redirects.

failed_links

Version: