37,720
社区成员
发帖
与我相关
我的任务
分享
# encoding:UTF-8
import sys
import re
from urllib2 import Request, urlopen, URLError, HTTPError
def get_packet(url):
packet = urlopen(url)
content = packet.read()
return content
def get_data(packet):
xiangmu = '~'
tmp = re.search(r'<a href=.*',packet)
if tmp is not None:
xiangmu = tmp.group().strip()
print xiangmu
if __name__=='__main__':
url = 'http://stock.finance.qq.com/corp1/cbsheet.php?zqdm=600787&type=2014'
packet = get_packet(url)
if packet =='~':
sys.exit(0)
get_data(packet)