cmd获取雪球股票行情实时数据
cmd获取雪球股票行情实时数据
## ball.py
import requests
import time
import pysnowball as ball
import argparse
def get_token():
r = requests.get("https://xueqiu.com", headers={"user-agent":"Mozilla"})
token = r.cookies["xq_a_token"]
# print(r.cookies["xq_a_token"])
return token
def cmd():
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('-s','--stock',default='SH000300',type=str,dest = "stock", help='an interger for the ball')
args = parser.parse_args()#返回一个命名空间,如果想要使用变量,可用args.attr
print(args)
snow_code = args.stock
return snow_code
if __name__ == "__main__":
start_time = time.time() # 开始时间
token_list = []
token = get_token()
token_list.append(token)
ball.set_token('xq_a_token={token};'.format(token=token_list[0]))
snow_code = cmd()
# print(snow_code)
# snow_code = ball.cash_flow('SH600000')
snow_current=ball.quotec(snow_code)
print(snow_current)
end_time = time.time() #结束时间
# print("程序耗时%f秒." % (end_time - start_time))
主要是cmd的命令框用法
{
'扬农化工':'SH600486',
'中公教育':'SZ002607'
}
cd /home/ball
python ball.py -s SH600486