from datetime import *
import os,re
import urllib.request
NewHight = "http://money.finance.sina.com.cn/quotes_service/api/jsonp_v2.php/IO.XSRV2.CallbackList['GiekxxaLquWt9var']/StatisticsService.getNewHighList?page=1&num=50&sort=changes&asc=0&node=adr_hk"
VolumeRiseCon = "http://money.finance.sina.com.cn/quotes_service/api/jsonp_v2.php/IO.XSRV2.CallbackList['EZBfg_Y31Rf9H0u_']/StatisticsService.getVolumeRiseConList?page=1&num=50&sort=changes&asc=0&node=adr_hk"
StockRiseCon = "http://money.finance.sina.com.cn/quotes_service/api/jsonp_v2.php/IO.XSRV2.CallbackList['t5EMB_i_mXBQgad2']/StatisticsService.getStockRiseConList?page=1&num=50&sort=day_con&asc=0&node=adr_hk"
StockRise = "http://money.finance.sina.com.cn/quotes_service/api/jsonp_v2.php/IO.XSRV2.CallbackList['t5EMB_i_mXBQgad2']/StatisticsService.getStockRiseList?page=1&num=50&sort=day_con&asc=0&node=adr_hk"
Urls = [NewHight,VolumeRiseCon,StockRiseCon,StockRise]
Symbols = set()
def load_info():
today = date.today()
dir = "Image" + str(today)
if (os.path.exists(dir) == False):
os.mkdir(dir)
for item in Urls:
text = urllib.request.urlopen(item).read().decode("gbk").encode("utf8")
text = str(text)
item = item.replace("asc=0","asc=1")
#text += urllib.request.urlopen(item).decode("gbk").encode("utf8")
text += str(urllib.request.urlopen(item).read().decode("gbk").encode("utf8"))
Symbols.update(re.findall("s[h,z][^3]\d{5}",text))#去掉创业板
print(Symbols)
print(len(Symbols))
def filter():
f = open("Info.txt","r").read()
f = str(f)
print(f)
if (f == None):
print("failed to open")
return -1
#symbols = re.findall("s[h,z][^3]\d{5}",f)
symbols = re.findall("s[h,z]\d{6}",f)
print(symbols)
load_info()
#filter()