【问题标题】:I need to get news article data. I'm using request/get from python but I got this error: 403 forbidden我需要获取新闻文章数据。我正在使用来自 python 的请求/获取,但出现此错误:403 禁止
【发布时间】:2023-04-03 10:59:02
【问题描述】:

代码如下:

from requests import get
from bs4 import BeautifulSoup

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'}

url = 'https://business.inquirer.net/category/latest-stories/page/10'
response = get(url)
print(response.text[:500])
html_soup = BeautifulSoup(response.text, 'html.parser')
type(html_soup)

这是我得到的结果:

<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>

我已经读过放置一个标题将解决错误,但我尝试放置我在检查站点时从 devtool 复制的标题,但它并没有解决我的问题
请帮帮我

【问题讨论】:

    标签:
    python
    html
    python-requests