0%
世界上最廉价的东西就是男人一事无成时的温柔。
.strings 和 stripped_strings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
from bs4 import BeautifulSoup import requests url = 'http://www.tripadvisor.cn/Attractions-g60763-Activities-New_York_City_New_York.html' wbData = requests.get(url) response = BeautifulSoup(wbData.text,'lxml') titles = response.select('div.property_title > a[target="_blank"]') images = response.select('img[width:"160"]') cates = response.select('div.p13n_reasoning_v2') for title,image,cate in zip(titles,images,cates): data = { 'title':title.get_text(), 'image':image.get('src'), 'cate':list(cate.stripped_strings) } print(data)
|