【发布时间】:2019-09-11 15:05:03
【问题描述】:
我正在尝试抓取此网站: https://www.footpatrol.com/
但是,该网站似乎拒绝了我的抓取尝试。
使用标题没有帮助。
from bs4 import BeautifulSoup
import requests
url = "https://www.footpatrol.com/"
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
r = requests.get(url, headers = headers)
data = r.text
soup = BeautifulSoup(data, 'lxml')
for a in soup.find_all():
print(a)
这导致我收到 ConnectionError,如何修复我的代码以便抓取网站?
【问题讨论】:
-
你想要的输出是什么?
-
@DirtyBit 现在我只想要完整的源代码,剩下的我自己做
-
您想要完整的源代码?好的。
标签: python web-scraping beautifulsoup python-requests screen-scraping