So I have been working with fake_useragent
for a web-scraping project:
from fake_useragent import UserAgent
ua = UserAgent()
headers = {
"User-Agent":ua.random
}
But I recently received this error in 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
The code worked well two days ago. I got confused.
Ok,I got it.pip install --upgrade fake-useragent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With