“达到最大重试次数”包 fake_useragent Python 3

Zip*_*Zip 3 python linux user-agent python-3.x

所以我一直在致力于fake_useragent一个网络抓取项目:

from fake_useragent import UserAgent
ua = UserAgent()
headers = {
    "User-Agent":ua.random
}
Run Code Online (Sandbox Code Playgroud)

但我最近在 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
Run Code Online (Sandbox Code Playgroud)

该代码前两天运行良好。我很困惑。

Zip*_*Zip 7

好,我知道了。pip install --upgrade fake-useragent