赞
踩
# coding=utf-8
from tkinter import *
import urllib.request
root = Tk()
root.title = "今日头条"
root.geometry("450x560")
can = Canvas(root,width=400,height=560,bg="orange")
can.pack()
url = "http://www.mnw.cn/news/top/"
data = urllib.request.urlopen(url).read().decode("UTF-8")
res = '<a\starget.*?>(.*?)</a>'
ress = '<a\starget.*?>\s*(.*?)\s*</a>'
resss = '<a.*?>(.*?)</a>'
res_two = '<p>\s*(.*?)\s*</p>'
result = re.findall(res, data)
results = re.findall(ress, data)
resultss = re.findall(resss, data)
result_two = re.findall(res_two, data)
k = 0
for i in result:
print(i)
k = k + 20
can.create_text(200, k, text=i)
#for i in resultss:
# print("bbbb")
# print(i)
# for i in result_two:
# print("aaaaaa")
can.mainloop()
# print(i)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。