python api

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')

 

posted @ 2017-01-03 23:27  为生活而努力  阅读(131)  评论(0编辑  收藏  举报