# coding: utf-8
import os
import re
import sys
import star
import requests
# reload(sys)
# sys.setdefaultencoding("utf-8")
# 基金代码
fundIds = ['000051', '519156', '', '000524', '000960', '163110','000457', '', '519669', '000961','000962','420001', '000697',
'470028', '470009', '001410', '', '110026', '110029', '000603', '', '150182']
def getInfo(url):
html = star.gethtml(url)
text = re.findall('class=\"fundDetail-tit\">(.*?)class=\"dataOfFund-line\"', html, re.S)[0]
text = text.decode('utf-8', 'ignore') #转换为unicode
info = re.findall('(.*?)\(*<.*?ui-num\">(.*?)<', text, re.S)[0]
id = info[1]
name = info[0]
statuszdf = re.findall('"gz_gztime">(.*?)<.*?"gz_gszzl">(.*?)<', text, re.S)[0]
rate = statuszdf[1]
updatetime = statuszdf[0]
print id, rate, name, updatetime
for fundid in fundIds:
if fundid=='':
print ''
else:
url = 'http://fund.eastmoney.com/{}.html'.format(fundid)
getInfo(url)
# break
os.system('pause')
000051 +1.98% 华夏沪深300ETF联接 (16-04-13 11:30)
519156 +1.85% 新华行业灵活配置混合A (16-04-13 11:30)
000960 +1.29% 招商医药健康产业股票 (16-04-13 11:30)
000524 +2.09% 上投摩根民生需求 (16-04-13 11:30)
163110 +2.00% 申万量化小盘 (16-04-13 11:30)
000457 +1.85% 上投摩根核心成长 (16-04-13 11:30)
519669 -0.01% 银河领先债券 (16-04-13 11:30)
000961 +1.98% 天弘沪深300指数型发起式 (16-04-13 11:30)
000962 +2.14% 天弘中证500指数型发起式 (16-04-13 11:30)
420001 +1.93% 天弘精选 (16-04-13 11:30)
000697 +2.06% 汇添富移动互联股票 (16-04-13 11:30)
470028 +2.34% 汇添富社会责任混合 (16-04-13 11:30)
470009 +1.91% 汇添富民营活力混合 (16-04-13 11:30)
001410 +1.76% 信达澳银新能源产业股票 (16-04-13 11:30)
110026 +2.18% 易方达创业板联接 (16-04-13 11:30)
110029 +2.00% 易方达科讯混合 (16-04-13 11:30)
000603 +2.17% 易方达创新驱动灵活配置 (16-04-13 11:30)
150182 +3.36% 富国中证军工指数分级B (16-04-13 11:30)
请按任意键继续. . .
# coding: utf-8
import os
import re
import sys
import star
import requests
# reload(sys)
# sys.setdefaultencoding("utf-8")
# 基金代码
fundIds = ['000051', '519156', '', '000524', '000960', '163110','000457', '', '519669', '000961','000962','420001', '000697',
'470028', '470009', '001410', '', '110026', '110029', '000603', '', '150182']
def getInfo(url):
html = star.gethtml(url)
html = html.decode('utf-8', 'ignore') #转换为unicode
name = re.search(r'<title>(.*?\))', html, re.S).group(1)
text = re.search(r'class=\"fundDetail-tit\">(.*?)class=\"dataOfFund-line\"', html, re.S).group(1)
statuszdf = re.search(r'"gz_gztime">(.*?)<.*?"gz_gszzl">(.*?)<', text, re.S)
rate = statuszdf.group(2)
updatetime = statuszdf.group(1)
print rate, name, updatetime
for fundid in fundIds:
if fundid=='':
print ''
else:
url = 'http://fund.eastmoney.com/{}.html'.format(fundid)
getInfo(url)
# break
os.system('pause')