百度api 找到當前電話號碼歸屬地


第一種通過百度api找到電話號碼歸屬地
import requests

def get_location(phone_num):
path = 'http://mobsec-dianhua.baidu.com/dianhua_api/open/location'
result = requests.get(path, params={'tel': phone_num}, timeout=10).json()
  return result

==>
{'response': {'18*********8': {'detail': {'area': [{'city': '九江'}], 'province': '江西', 'type': 'domestic', 'operator': '移動'}, 'location': '江西九江移動'}}, 'responseHeader': {'status': 200, 'time': 1545209598689, 'version': '1.1.0'}}

第二種,通過Python內置模塊phone

import phone      #開始要下載phone模塊,  pip install phone

def get_location(phone_num):
    p = phone.Phone()
    result = p.find(phone_num)
    return result

==>
{'phone': '18770223348', 'province': '江西', 'city': '九江', 'zip_code': '332000', 'area_code': '0792', 'phone_type': '移動'}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM