【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《基于Python的QQ号码测吉凶api调用代码实例》,欢迎阅读!

基于Python的QQ号码测吉凶api调用代码实例
代码描述:基于Python的QQ号码测吉凶api调用代码实例 代码平台:聚合数据
#!/usr/bin/python
# -*- coding: utf-8 -*- import json, urllib
from urllib import urlencode
#----------------------------------
# QQ号码测吉凶调用示例代码 - 聚合数据
# 在线接口文档:http://www.juhe.cn/docs/166 #----------------------------------
def main():
#配置您申请的APPKey
appkey = "*********************"
#1.QQ号码测吉凶
request1(appkey,"GET")
#QQ号码测吉凶
def request1(appkey, m="GET"):
url = "http://japi.juhe.cn/qqevaluate/qq" params = {
"key" : appkey, #您申请的appKey "qq" : "", #需要测试的QQ号码
}
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()
本文来源:https://www.wddqxz.cn/a5b893e516fc700aba68fc6f.html