标签:rom x64 技术 open == 技术分享 display init server
import requests import logging import logging.config import random import os import yaml class Observer(object): open_price_last_1 = ‘‘ close_price_last_1 = ‘‘ highest_price_last_1 = ‘‘ minimum_price_last_1 = ‘‘ ding_fen_xing = [] di_fen_xing = [] not_ding_di = [] def __init__(self): path = ‘logging.yaml‘ value = os.getenv(‘LOG_CFG‘, None) if value: path = value if os.path.exists(path): with open(path, "r") as f: config = yaml.load(f) logging.config.dictConfig(config) else: print(‘log config file not found!‘) def get_stock_data(self,stock_code,scale): #url = ‘http://ifzq.gtimg.cn/appstock/app/kline/mkline?param=sh600030,m30,,320&_var=m30_today&r=0.1700474168906776‘ url = ‘http://ifzq.gtimg.cn/appstock/app/kline/mkline‘ headers = {‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36‘} params = { ‘param‘: ‘{},m{},,320‘.format(stock_code,scale), ‘_var‘: ‘m{}_today‘.format(scale), ‘r‘: ‘0.1700474{}‘.format("".join(random.choice("0123456789") for i in range(10))) } logging.info(‘url:%s \t params:%s‘,url,params) res = requests.get(url,params=params,headers=headers) logging.info(res.text) def get_stock_code(self,a_type): #url = ‘http://stock.gtimg.cn/data/index.php?appn=rank&t=rankash/chr&p=1&o=0&l=40&v=list_data‘ url = ‘http://stock.gtimg.cn/data/index.php‘ headers = { ‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36‘} params = { ‘appn‘: ‘rank‘, ‘t‘: ‘ranka{}/chr‘.format(a_type), ‘p‘: 1, ‘o‘: 0, ‘l‘: 3000, ‘v‘: ‘list_data‘ } logging.info(‘url:%s \t params:%s‘, url, params) res = requests.get(url, params=params, headers=headers) logging.info(res.text) if __name__ == ‘__main__‘: o = Observer() #o.get_stock_data(‘sh600030‘,‘30‘) o.get_stock_code(‘sh‘) o.get_stock_code(‘sz‘)
标签:rom x64 技术 open == 技术分享 display init server
原文地址:https://www.cnblogs.com/xiaodebing/p/9857303.html