Python phone模塊獲取手機(jī)號(hào)歸屬地 區(qū)號(hào) 運(yùn)營商等信息demo
更新時(shí)間:2023年05月30日 09:53:03 作者:移動(dòng)安全星球
這篇文章主要介紹了Python phone模塊獲取手機(jī)號(hào)歸屬地 區(qū)號(hào) 運(yùn)營商等信息的實(shí)現(xiàn)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
一、使用
我使用的是python3,可以自行搜索下載
二、安裝
phone模塊
pip install phone
三、測(cè)試
代碼如下:
from phone import Phone
if __name__ == "__main__":
phoneNum = '17613394466'
info = Phone().find(phoneNum)
print(info)
try:
phone = info['phone']
province = info['province']
city = info['city']
zip_code = info['zip_code']
area_code = info['area_code']
phone_type = info['phone_type']
except:
print('none')四、批量查詢excle中已有的電話號(hào)
from phone import Phone
import xlrd
import xlwt
def Get_Excel_data():
file = './Tel.xlsx' #電話號(hào)碼存儲(chǔ)的excle表
re1 = xlrd.open_workbook(file)
outwb = xlwt.Workbook() #創(chuàng)建工作簿
# print(type(outwb))
outws = outwb.add_sheet("new") #在工作簿中新建一個(gè)工作表new
# print(type(outws))
# 讀取第一個(gè)sheet
ws = re1.sheet_by_index(0)
rows = ws.nrows
# print(rows)
outws.write(0, 0, u'電話號(hào)') #給新表的第一行添加對(duì)應(yīng)的標(biāo)簽
outws.write(0, 1, u'省份')
outws.write(0, 2, u'城市')
outws.write(0, 3, u'區(qū)號(hào)')
outws.write(0, 4, u'運(yùn)營商')
for i in range(0, rows):
Telvalue = int(ws.cell_value(i, 0))
# print(Telvalue)
data = Phone().find(Telvalue)
print(data)
outws.write(i + 1, 0, Telvalue) #給新表的個(gè)列添加對(duì)應(yīng)的數(shù)據(jù)
try:
outws.write(i + 1, 1, data['province'])
outws.write(i + 1, 2, data['city'])
outws.write(i + 1, 3, data['area_code'])
outws.write(i + 1, 4, data['phone_type'])
outwb.save(r'New_Tel.xls')
except:
print("none")
Get_Excel_data()以上就是Python phone模塊獲取手機(jī)號(hào)歸屬地 區(qū)號(hào) 運(yùn)營商等信息demo的詳細(xì)內(nèi)容,更多關(guān)于Python phone獲取手機(jī)號(hào)信息的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
pyqt5 實(shí)現(xiàn)工具欄文字圖片同時(shí)顯示
今天小編就為大家分享一篇pyqt5 實(shí)現(xiàn)工具欄文字圖片同時(shí)顯示的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-06-06
Python Requests模擬登錄實(shí)現(xiàn)圖書館座位自動(dòng)預(yù)約
這篇文章主要為大家詳細(xì)介紹了Python Requests的模擬登錄,Python實(shí)現(xiàn)圖書館座位自動(dòng)預(yù)約,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-04-04
Python中類創(chuàng)建和實(shí)例化的過程詳解
這篇文章主要介紹了Python中類創(chuàng)建和實(shí)例化過程,文中通過代碼示例講解的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下2024-06-06
Python+Pyecharts實(shí)現(xiàn)散點(diǎn)圖的繪制
散點(diǎn)圖是指在回歸分析中,數(shù)據(jù)點(diǎn)在直角坐標(biāo)系平面上的分布圖,散點(diǎn)圖表示因變量隨自變量而變化的大致趨勢(shì),據(jù)此可以選擇合適的函數(shù)對(duì)數(shù)據(jù)點(diǎn)進(jìn)行擬合。本文將利用Python Pyecharts實(shí)現(xiàn)散點(diǎn)圖的繪制,需要的可以參考一下2022-06-06

