码迷,mamicode.com
首页 > 其他好文 > 详细

stock

时间:2018-10-26 17:48:58      阅读:100      评论:0      收藏:0      [点我收藏+]

标签: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)
View Code

 

stock

标签:rom   x64   技术   open   ==   技术分享   display   init   server   

原文地址:https://www.cnblogs.com/xiaodebing/p/9857303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!