I tried to use fake_useragent
module with this block
from fake_useragent import UserAgent
ua = UserAgent()
print(ua.random)
But when the execution reached this line ua = UserAgent()
, it throws this error
Traceback (most recent call last):
File "/home/hadi/Desktop/excel/gatewayform.py", line 191, in <module>
gate = GateWay()
File "/home/hadi/Desktop/excel/gatewayform.py", line 23, in __init__
ua = UserAgent()
File "/usr/local/lib/python3.9/dist-packages/fake_useragent/fake.py", line 69, in __init__
self.load()
File "/usr/local/lib/python3.9/dist-packages/fake_useragent/fake.py", line 75, in load
self.data = load_cached(
File "/usr/local/lib/python3.9/dist-packages/fake_useragent/utils.py", line 250, in load_cached
update(path, use_cache_server=use_cache_server, verify_ssl=verify_ssl)
File "/usr/local/lib/python3.9/dist-packages/fake_useragent/utils.py", line 245, in update
write(path, load(use_cache_server=use_cache_server, verify_ssl=verify_ssl))
File "/usr/local/lib/python3.9/dist-packages/fake_useragent/utils.py", line 178, in load
raise exc
File "/usr/local/lib/python3.9/dist-packages/fake_useragent/utils.py", line 154, in load
for item in get_browsers(verify_ssl=verify_ssl):
File "/usr/local/lib/python3.9/dist-packages/fake_useragent/utils.py", line 99, in get_browsers
html = html.split('<table class="w3-table-all notranslate">')[1]
IndexError: list index out of range
I use linux and I have installed the module using this command pip3 install fake_useragent --upgrade
.
Is there any solution for this issue? if not, is there a better module to use?
html = html.split('<table class="w3-table-all notranslate">')[1]
and not thefake_useragent
. – Prolongutils.py
which is in thefake_useragent
module – Nitro