1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| def getHouseDetail(url): info={} info_adj={} res=requests.get(url) soup = BeautifulSoup(res.text,'html.parser') info['标题']=soup.select('.title h1')[0].text.strip() info['总价']=soup.select('.price_esf')[0].text
for item in soup.select('.trl-item1'): key=item.select('.font14')[0].text.strip() print(key) value=item.select('.tt')[0].text.strip() info[key]=value k=['总价','单价','建筑面积','朝向','楼层','装修','户型','标题'] info_adj=dict(zip(k,list(info.values()))) return info_adj
|