#coding=utf-8
'''
股票历史数据抓取
'''
import time
import logging
import requests
import json
import re
LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
logging.basicConfig(filename='run.log', level=logging.DEBUG, format=LOG_FORMAT)
# logging.debug("This is a debug log.")
# logging.info("This is a info log.")
# logging.warning("This is a warning log.")
# logging.error("This is a error log.")
# logging.critical("This is a critical log.")
f = open('stocklist.html','r',encoding='utf-8')
html = f.read()
# <li><a target="_blank" href="http://quote.eastmoney.com/sh512100.html">1000ETF(512100)</a></li>
ones = re.findall('<li>.*?html">(.*?)</a></li>',html,re.M|re.S)
stock = {}
for i in ones:
print('-----------------')
name = i.split('(')[0]
code = i.split('(')[1].split(')')[0]
stock[code] = name
print(len(ones))
print(stock)
# if len(one) != 0 and version == ‘None’:
one = re.findall( r’.专有云版本 : (.?)\n.*’, str(line), re.M|re.S)
if len(one) != 0 and version == ‘None’:
print(one[-1])
version = one[-1]