Urllib.request-urlopen opens a URL, and the server will only receive a simple request for page access, but the server does not know the browser, operating system, hardware platform and other information used to send the request, and the request without this information is often non-normal access, such as crawler.
In order to prevent this abnormal access, some websites will verify the UserAgent in the request information (its information includes hardware platform, system software, application software, and user preferences). If the UserAgent is abnormal or does not exist, then the request will be rejected (as shown in the error message above).
Add the browser camouflage [see link for method].
headers = {'User-Agent':'Mozilla/5.0 3578.98 Safari/537.36'}
url = Request(url,headers=headers)
content = urlopen(url,timeout=15).read()
Read More:
- urllib.error.HTTPError: HTTP Error 403: Forbidden [How to Solve]
- Python error: urllib.error.HTTPError : http Error 404: not found
- How to Fix “HTTP error 403: forbidden” in Python 3. X
- Python 3 urllib has no URLEncode attribute
- [Solved] HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/saved_model
- SSL error of urllib3 when Python uploads files using Minio
- [Solved] Forbidden (403) CSRF verification failed. Request aborted.
- [Solved]AttributeError: module ‘urllib’ has no attribute ‘quote’
- urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘localhost‘, port=8097): Max retries excee
- [Solved] urllib.error.URLError: <urlopen error [SSL: WRONG_VERSION_NUMBER] wrong version number
- [Solved] Conda install Error: An HTTP error occurred when trying to retrieve this URL. HTTP errors are often…
- [Solved] raise ContentTooShortError(urllib.error.ContentTooShortError: <urlopen error retrieval incomplete:
- [Solved] urllib.error.URLError: urlopen error [SSL: CERTIFICATE_VERIFY_FAILED]
- urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>
- [Solved] Pytorch Download CIFAR1 Datas Error: urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certi
- Error when downloading the built-in dataset of pytoch = urllib.error.urlerror: urlopen error [SSL: certificate_verify_failed]
- When sending HTTP request, python encountered: error 54, ‘connection reset by peer’ solution
- odoo Error: KeyError:‘ir.http‘ [How to Solve]
- [Solved] Connection Error: couldn‘t reach http://raw.githubusercontent.com/huggingface/…