import requests
#查询手机好归属地API
def phone(tel):
url = ‘http://op.juhe.cn/onebox/phone/query‘
appkey = ‘4361fbde3d9ea1be11ae38bdff1a522‘
params = {‘tel‘:tel,‘key‘:appkey}
res = requests.get(url,params=params).json()
if res[‘error_code‘] == 0:
print res[‘result‘][‘province‘],res[‘result‘][‘city‘],res[‘result‘][‘sp‘]
if __name__ == ‘__main__‘:
phone(‘186xxxxxxxx‘)
时间: 2024-11-10 07:47:31