导入的库---requests,bs4
import requests,bs4,tkinter
让别人输入日期
a=input("您要查询的月份(必须两位数,1月请输入01):")
b=input("您要查询的日期(必须两位数,1日请输入01):")
了解360网站并爬取(用requests.get)
imformation=requests.get("http://hao.360.com/histoday/"+str(c)+".html").text
找到里面class,name标签,并用bs4的BeatifulSoup整理
s=bs4.BeautifulSoup(imformation,"lxml").find_all(name='div',class_='tih-list')
用for循环遍历列表并打印就行了!(每一天的历史事件数量是不同的哦!)
for x in s:
xx=x.find_all(name="dt")
for y in s:
yy=y.find_all(class_="desc")
for i in range(100):
try:
a=xx[i].text
except:
break