fake_useragent.errors.FakeUserAgentError: Error occurred during getting browser
来源:8-5 通过downloadmiddleware随机更换user-agent - 2
发现世界搜索引擎
2020-06-28
fake_useragent.errors.FakeUserAgentError: Error occurred during getting browser 使用这个为什么报错这个的呢?
我在百度上找不到这个解决方案
I am getting the same issue with creating a fake_useragent object.
from fake_useragent import UserAgent
ua = UserAgent()
Results in :
Traceback (most recent call last):
File “filepath\lib\site-packages\fake_useragent\fake.py”, line 136, in getattr
return random.choice(self.data_browsers[browser])
KeyError: 'len’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “filepath\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\193.6494.30\plugins\python\helpers\pydev_pydevd_bundle\pydevd_thrift.py”, line 274, in frame_vars_to_struct
value = var_to_struct(v, str(k), evaluate_full_value=eval_full_val)
File “filepath\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\193.6494.30\plugins\python\helpers\pydev_pydevd_bundle\pydevd_thrift.py”, line 358, in var_to_struct
elif hasattr(v, ‘len’) and not is_string(v):
File “filepath\lib\site-packages\fake_useragent\fake.py”, line 139, in getattr
raise FakeUserAgentError(‘Error occurred during getting browser’) # noqa
fake_useragent.errors.FakeUserAgentError: Error occurred during getting browser
Unexpected error, recovered safely.
I am using Python 3.7.
1回答
-
bobby
2020-06-28
换个user agent库试试 https://github.com/alecxe/scrapy-fake-useragent 比如这个
00
相似问题