相关疑难解决方法(0)

请求返回响应 447

我正在尝试使用请求和 BeautifulSoup 来抓取网站。当我运行代码来获取网页的标签时,soup 对象是空白的。我把请求对象打印出来看看请求是否成功,没有。打印结果显示响应 447。我无法找到 447 作为 HTTP 状态代码的含义。有谁知道我如何成功连接和抓取网站?

代码:

r = requests.get('https://foobar)
soup = BeautifulSoup(r.text, 'html.parser')
print(soup.get_text())

Output:
''
Run Code Online (Sandbox Code Playgroud)

当我打印请求对象时:

print(r)

Output:
<Response [447]>
Run Code Online (Sandbox Code Playgroud)

http beautifulsoup request web-scraping python-3.x

1
推荐指数
1
解决办法
748
查看次数

标签 统计

beautifulsoup ×1

http ×1

python-3.x ×1

request ×1

web-scraping ×1