我知道这是一个头的问题,因为如果我把头从我的代码中去掉,那么html就会说我是一个机器人,但是我甚至在添加头的时候也无法解决这个问题。你能给我什么建议?在
import requests
from bs4 import BeautifulSoup
#Get the different pages to begin scraping data from
url = "http://www.manta.com/mb_41_ALL_19/louisiana"
headers = { 'Origin':'http://www.manta.com',
'Referer':'http://www.manta.com/mb_41_ALL_19/louisiana',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'
, 'Accept-Language':'en-US,en;q=0.8'
,'Content-Type':'text/html; charset=utf-8', 'Host':None,}
newurl = requests.get(url, headers=headers)
soup = BeautifulSoup(newurl.text, "html.parser")
print(soup)
坏消息是,看看你在
body
上得到了什么:distil
是“Distil Networks”反网页抓取服务的标志。他们有自己的理由。引用"Terms of Service":从技术上讲,你可以挑战Distil,但在法律上你不应该。在
相关问题 更多 >
编程相关推荐