Python编程学习笔记 随时更新
import urllib.request import re 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/20160612/(.*?).shtml' target='_blank'>(.*?)</a>",re.S) items = re.findall(pattern,html) for item in items: print(item[1]) #print(html)