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)

 

posted @ 2016-03-17 12:42  疯陈演义  阅读(232)  评论(0编辑  收藏  举报