我试图刮这个网站:https://www.senate.gov/general/contact_information/senators_cfm.cfm
我的代码:
import requests
from bs4 import BeautifulSoup
URL = 'https://www.senate.gov/general/contact_information/senators_cfm.cfm'
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup)
问题是它实际上并没有进入网站,我在soup var中得到的HTML与正确网页中的HTML完全不同。
2条答案
按热度按时间ldfqzlk81#
这对我很有效
在此处找到信息-https://towardsdatascience.com/5-strategies-to-write-unblock-able-web-scrapers-in-python-5e40c147bdaf
i2loujxw2#
复制HTTP 503 Error while using python requests module
试试看: