【发布时间】:2020-10-02 20:25:23
【问题描述】:
这是我第一次遇到一个“不允许我访问”网页的网站。我不知道为什么,也不知道如何从这个网站上抓取。
我的尝试:
import requests
from bs4 import BeautifulSoup
def html(url):
return BeautifulSoup(requests.get(url).content, "lxml")
url = "https://www.g2a.com/"
soup = html(url)
print(soup.prettify())
输出:
<html>
<head>
<title>
Access Denied
</title>
</head>
<body>
<h1>
Access Denied
</h1>
You don't have permission to access "http://www.g2a.com/" on this server.
<p>
Reference #18.4d24db17.1592006766.55d2bc1
</p>
</body>
</html>
我已经研究了一段时间,发现应该有某种类型的token [访问、刷新等...]。
还有,action="/search",但我不知道该怎么办。
【问题讨论】:
-
这能回答你的问题吗? Scraper in Python gives "Access Denied"
-
我认为这是为了防止“机器人”访问该页面,上面的评论建议另一篇有修复的帖子
标签: python web-scraping python-requests