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

使用launcher_new.py出现fake_useragent.errors.FakeUserAgentError: Maximum amount of retries reached的解决方案 #24

Closed
theLSA opened this issue Jul 10, 2021 · 2 comments

Comments

@theLSA
Copy link
Contributor

theLSA commented Jul 10, 2021

launcher_new.py使用了fake-useragent可能会出现报错:
fake_useragent.errors.FakeUserAgentError: Maximum amount of retries reached

本人尝试了如下解决方案:

先:
pip3 install --upgrade fake_useragent

1.修改代码launcher_new.py第十一行
ua = UserAgent(use_cache_server=False,verify_ssl=False,cache=False)

2.利用临时文件
下载https://fake-useragent.herokuapp.com/browsers/0.1.11 //好像国内无法访问
改名为fake_useragent_0.1.11.json
放入临时文件夹(如/tmp)

import tempfile
tempfile.gettempdir()

都无法解决

查看代码site-packages/fake_useragent/settings.py
发现要请求BROWSERS_STATS_PAGE = 'https://www.w3schools.com/browsers/default.asp'
但是该url好像国内无法访问所以报该错误

所以建议使用国外vps,或者弃用fake-useragent库。

@yhy0
Copy link

yhy0 commented Jul 23, 2021

选用第二种方法,将 https://fake-useragent.herokuapp.com/browsers/0.1.11 下载的文件与launcher_new.py放入同一目录,然后修改代码launcher_new.py第十一行 为
ua = UserAgent(path="fake_useragent.json")
修改为自己的下载的文件名即可

@timwhitez
Copy link
Owner

感谢

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

3 participants