Traceback (most recent call last):
  File "/Users/kyz/Desktop/py3env/lib/python3.7/site-packages/fake_useragent/utils.py", line 154, in load
    for item in get_browsers(verify_ssl=verify_ssl):
  File "/Users/kyz/Desktop/py3env/lib/python3.7/site-packages/fake_useragent/utils.py", line 97, in get_browsers
    html = get(settings.BROWSERS_STATS_PAGE, verify_ssl=verify_ssl)
  File "/Users/kyz/Desktop/py3env/lib/python3.7/site-packages/fake_useragent/utils.py", line 84, in get
    raise FakeUserAgentError('Maximum amount of retries reached')
fake_useragent.errors.FakeUserAgentError: Maximum amount of retries reached

原因是使用

ua = UserAgent().chrome 
from fake_useragent import UserAgent这个库导致的 

应该仅用了缓存如果还是无效就把文件下下来 https://fake-useragent.herokuapp.com/browsers/0.1.11

path = os.path.join(FILE_DIR, 'fake_ua.json') # path 为你放置 fake_ua.json文件路径

fake_ua = fake_useragent.UserAgent(path=path).random print(fake_ua)

ua = UserAgent(use_cache_server=False)
Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐