标签:
import urllib.request import re from tkinter import * win = Tk() win.geometry(‘500x300+400+300‘) t = Text(win) t.pack() url = ‘http://stock.sohu.com/news/‘ html = urllib.request.urlopen(url).read() html = html.decode(‘GBK‘) pattern = re.compile("<a test=a href=‘http://stock.sohu.com/(.*?)/(.*?).shtml‘ target=‘_blank‘>(.*?)</a>",re.S) items = re.findall(pattern,html) for item in items: t.insert(END,item[2]) t.insert(END,‘\n‘)
标签:
原文地址:http://www.cnblogs.com/wumac/p/5828275.html