下厨房本周最受欢迎菜品:
http://www.xiachufang.com/explore/
爬取代码:
import requests
from bs4 import BeautifulSoup
res=requests.get('http://www.xiachufang.com/explore/')
html=res.text
soup=BeautifulSoup(html,'html.parser')
items=soup.find_all(class_="info pure-u")
for item in items:
name=item.find(class_="name")
materials=item.find(class_="ing ellipsis")
url=item.find(target="_blank")
print(name.text.strip(),'\n','材料:'+materials.text.strip(),'\n','地址:'+'http://www.xiachufang.com'+url['href'])
print()
运行终端: