苹果手机查看python代码_[代码全屏查看]-基于Python的苹果序列号官网查询接口调用代码实例...

[1].[代码] [Python]代码

#!/usr/bin/python

# -*- coding: utf-8 -*-

import json, urllib

from urllib import urlencode

#----------------------------------

# 苹果序列号调用示例代码 - 聚合数据

# 在线接口文档:http://www.juhe.cn/docs/37

#----------------------------------

def main():

#配置您申请的APPKey

appkey = "*********************"

#1.苹果序列号/IMEI号查询

request1(appkey,"GET")

#苹果序列号/IMEI号查询

def request1(appkey, m="GET"):

url = "http://apis.juhe.cn/appleinfo/index"

params = {

"sn" : "", #苹果产品的序列号或IMEI号

"dtype" : "", #返回数据格式:json或xml,默认json

"key" : appkey, #你申请的key

}

params = urlencode(params)

if m =="GET":

f = urllib.urlopen("%s?%s" % (url, params))

else:

f = urllib.urlopen(url, params)

content = f.read()

res = json.loads(content)

if res:

error_code = res["error_code"]

if error_code == 0:

#成功请求

print res["result"]

else:

print "%s:%s" % (res["error_code"],res["reason"])

else:

print "request api error"

if __name__ == '__main__':

main()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值