python - 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>
解决方案
推荐阅读
- javascript - 每个数组的 Javascript 回显,同时还从字符串转换为整数
- mysql - 修复了 Laravel Eloquent 中的 updated_at 错误
- swift - 使用正则表达式或替代方法快速抓取网页
- c# - 为什么不统一完成 Update() 函数中的所有函数
- javascript - 如何在锚标记内使用 Javascript 变量作为 href?
- javascript - localStorage ReactJs 在推送时不工作
- python - 我可以使用 python 客户端库将通知从 RaspBerry Pi 发送到 python kivy 应用程序吗?
- javascript - 基本 JS:在光标位置添加字符,同时保持光标位置
- lua - 表排序索引名称 LUA
- java - 如何在 GUI 类中实现 Action Listener?