爱采购标题爬虫
import requests import re # https://b2b.baidu.com/s?q= key='建筑机械' url='https://b2b.baidu.com/s?q='+key data=requests.get(url).text tit ='"fullName":"(.*?)"' alltit = re.compile(tit,re.S).findall(data) for item in alltit: print(eval('u"'+str(item)+'"')) #eval 将字符串str当成有效的表达式子来求值并返回计算结果 print('--------------')