关于获取网页接口字典的处理,自动监控数字币

# coding=utf-8
import urllib,time,json
while 1:
time.sleep(3)
keywd = 'bcx_qc'
url = 'http://api.zb.com/data/v1/ticker?market=' + keywd
##req = urllib.request.Request(url)
data =eval(urllib.urlopen(url).read())
#data = float(urllib.urlopen(url).read()["ticker"]["last"])
m=data["ticker"]["last"]
print (m)
#bcx_price=float(data["ticker"]["last"])
bcx_price=float(data["ticker"]["last"])
print(bcx_price)
bcx_target=0.299
#判定
if bcx_price>=bcx_target:execfile('E:/python_project/getpost/message.py');
#print(keywd)
f = open('C:/buy/test1.txt','w')
f.write(str(keywd))
f.close()

 *********************************************************************************************************

import urllib, urllib2, sys
import ssl


host = 'https://feginesms.market.alicloudapi.com'
path = '/codeNotice'
method = 'GET'
appcode = 'eff9c489cd5ctr23yu466c8b248ad462a60b1c'
querys = 'param=bcxok&phone=18606108269&sign=1&skin=1'
bodys = {}
url = host + path + '?' + querys

request = urllib2.Request(url)
request.add_header('Authorization', 'APPCODE ' + appcode)
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urllib2.urlopen(request, context=ctx)
content = response.read()
if (content):
print(content)

posted on 2018-05-16 21:24  Areon  阅读(102)  评论(0)    收藏  举报

导航