簡體   English   中英

使用 Requests Python 抓取網頁

[英]Scraping web page with Requests Python

我想抓取此頁面,但在請求后我找不到帶有BeautifulSoup table

代碼

headers = {"Referer": "https://www.atptour.com/en/scores/results-archive",
            'User-Agent': 'my-user-agent'
        }
url = 'https://www.atptour.com/en/scores/results-archive?year=2016'
page = requests.get(url, headers=headers)
print(page)
soup = BeautifulSoup(page.text, 'html.parser')
table = soup.find('table', class_="results-archive-table mega-table")
print(table)

輸出<Response [403]> None

看看回復:

print(page)
<Response [403]>

也許您必須在請求中添加一些標頭。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM