Search code examples
pythonpython-3.xseleniumparsingbeautifulsoup

python parser Access to resource was blocked


When I try to parse HTML using python, the HTML says "access is denied".

import requests

headers = {"User-Agent": 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Mobile Safari/537.36'}
mvideo_requests =requests.get('https://www.mvideo.ru/smartfony-i-svyaz-10/smartfony-205/f/category=iphone-914', headers = headers)
    
    
print(mvideo_requests.text)

Output:

    <!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>Access Blocked</title>
</head>
<body>
    Access to resource was blocked.<br>
    Reason or support ID: ed2df5d3-5e17-4f3d-ae01-2f053d32a354.
</body>
</html>

 

Solution

  • I had the same issue, and the best answer I found was here: How to fix "403 Forbidden" errors when calling APIs using Python requests?

    Moreover, turning VPN off helped me too