爬取e展会2021年11月展会列表,地点,热度,时间,网址如下:
用bs4只能爬前两页内容,但实际上有四页内容。
查看xhr的preview,渲染成了页面,不是字典形式的代码,也无从爬起,而且目测展会信息好像也不全。
xhr文件的preview理论上应该是下图这种形式,但现在打开直接是页面。
看是否是json格式数据,不是在review中找,你要点击Resonse选项卡看看。
html格式的就不会了?
Html直接爬就行了
import requests
from lxml import etree
res = requests.post('http://www.eshow365.com/ZhanHui/Ajax/AjaxSearcherV3.aspx',
data={'starttime': '2021/11/1', 'startendtime': '2021/11/30', 'page': 2}).text
tree = etree.HTML(res)
divs = tree.xpath('//div[@class="sslist"]')
for div in divs:
text = div.xpath('string(./p[@class="cg"])')
title = div.xpath('string(./p[@class="zhtitle"])')
# text = text.strip()
print(title)
print(text)