首页 > 解决方案 > python解析器访问资源被阻止

问题描述

当我尝试使用 python 解析 HTML 时,HTML 显示“访问被拒绝”。

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)

输出:

    <!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>

 

标签: pythonpython-3.xseleniumparsingbeautifulsoup

解决方案


推荐阅读