帮忙分析一下用python爬取一个网站一直不成功的原因
headers={"Accept":headers={"text/html,application/xhtml+xml,application/xml;q=0.9,ima...
headers = {
"Accept":
headers={"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"DNT": "1",
"Host": "ha.chinaunicombidding.cn",
"Pragma": "no-cache",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"
}
url1='http://ha.chinaunicombidding.cn/jsp/cnceb/web/info1/infoList.jsp?notice=&time1=&time2=&province=&city=&type='
response = requests.get(url1, headers=headers)
text = response.content.decode('utf-8')
html = etree.HTML(text)
biaotis=html.xpath('//*[@id="div1"]/table/tbody/tr/td//text()') #招标公告标题
for biaoti in biaotis:
print(biaoti) 展开
"Accept":
headers={"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"DNT": "1",
"Host": "ha.chinaunicombidding.cn",
"Pragma": "no-cache",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"
}
url1='http://ha.chinaunicombidding.cn/jsp/cnceb/web/info1/infoList.jsp?notice=&time1=&time2=&province=&city=&type='
response = requests.get(url1, headers=headers)
text = response.content.decode('utf-8')
html = etree.HTML(text)
biaotis=html.xpath('//*[@id="div1"]/table/tbody/tr/td//text()') #招标公告标题
for biaoti in biaotis:
print(biaoti) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询