Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Maximum amount of retries reached" with package fake_useragent Python 3

So I have been working with fake_useragent for a web-scraping project:

from fake_useragent import UserAgent
ua = UserAgent()
headers = {
    "User-Agent":ua.random
}

But I recently received this error in Python 3:

Error occurred during loading data. Trying to use cache server file https://useragent.melroy.org/cache.json
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/fake_useragent/utils.py", line 64, in get
    urlopen(
  File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
....skip...

fake_useragent.errors.FakeUserAgentError: Maximum amount of retries reached

The code worked well two days ago. I got confused.

like image 252
Zip Avatar asked Sep 20 '25 12:09

Zip


1 Answers

Ok,I got it.pip install --upgrade fake-useragent

like image 69
Zip Avatar answered Sep 23 '25 03:09

Zip