新浪股票接口应用示例
import re import requests def market(st): market_code = "1" if st[0] == '6' else "0" return market_code + st gudaima = "sz000001" headers = {'referer': 'http://finance.sina.com.cn'} # resp = requests.get('http://hq.sinajs.cn/list=' + gudaima, headers=headers, timeout=6) resp = requests.get( 'https://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/MoneyFlow.ssl_bkzj_ssggzj?page=1&num=10&sort=netamount&bankuai=&shichang=' + gudaima, headers=headers, timeout=6) data = resp.text pattern = re.compile(r'symbol":"[a-z]{2}(\d{6})') res = pattern.findall(data) wan = list(map(market, res)) f = open(r'zqv6\T0002\blocknew\WS.blk', 'w') f.write('\n'.join(wan)) f.close()
参考:
https://baijiahao.baidu.com/s?id=1743186680668499252&wfr=spider&for=pc https://blog.csdn.net/withchris/article/details/62420085