import requests
from lxml.etree import HTML
from urllib.request import *
from tkinter import *
url = 'https://www.tianqijun.com/techan/doc/3711.html'
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
}
count=1
request = requests.get(url,headers=headers)
html = HTML(request.text)
text = html.xpath('//div[@class="detailText"]/p/text()')
nnn='\n'.join(text)
url="http://tqjimg.tianqistatic.com/toutiao/techan/images/201907/16/5056eee5774256bf3e65c99d1d85c456.jpg/tqj_pc"
c=urlopen(url)
c=c.read()
with open("石榴.gif","wb") as f:
f.write(c)
url="http://tqjimg.tianqistatic.com/toutiao/techan/images/201907/16/becb00f7ed7ce15d5348dff60aa3ccc3.jpg/tqj_pc"
c=urlopen(url)
c=c.read()
with open("花芒果.gif","wb") as f:
f.write(c)
count+=1
url="http://tqjimg.tianqistatic.com/toutiao/techan/images/201907/16/7b5de4c42958bcc8cb18ab3b8e327c28.jpg/tqj_pc"
c=urlopen(url)
c=c.read()
with open("米易雪梨.gif","wb") as f:
f.write(c)
count+=1
url="http://tqjimg.tianqistatic.com/toutiao/techan/images/201907/16/bb608a0996765258acc591644e0a5037.jpg/tqj_pc"
with open("米易早春枇杷.gif","wb") as f:
f.write(c)
count+=1
chuangkou=Tk()
t=Label(chuangkou, text=nnn, fg="green", font=6)
t.pack()
image=PhotoImage(file="石榴.gif")
w=Label(chuangkou, image=image)
w.pack()
image1=PhotoImage(file="花芒果.gif")
w1=Label(chuangkou, image=image1)
w1.pack()
image2=PhotoImage(file="米易雪梨.gif")
w2=Label(chuangkou, image=image2)
w2.pack()
image3=PhotoImage(file="米易早春枇杷.gif")
w4=Label(chuangkou, image=image3)
w4.pack()
mainloop()
|