Python(phone)模块获取手机号归属地、区号、运营商等

一、我使用的是python3,可以自行搜索下载

二、安装phone模块, pip install phone

三、测试代码如下:

from phone import Phone

if __name__ == "__main__":
phoneNum = ''
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中已有的电话号

from phone import Phone
import xlrd
import xlwt def Get_Excel_data():
file = './Tel.xlsx' #电话号码存储的excle表
re1 = xlrd.open_workbook(file) outwb = xlwt.Workbook() #创建工作簿
# print(type(outwb))
outws = outwb.add_sheet("new") #在工作簿中新建一个工作表new
# print(type(outws)) # 读取第一个sheet
ws = re1.sheet_by_index(0)
rows = ws.nrows
# print(rows)
outws.write(0, 0, u'电话号') #给新表的第一行添加对应的标签
outws.write(0, 1, u'省份')
outws.write(0, 2, u'城市')
outws.write(0, 3, u'区号')
outws.write(0, 4, u'运营商') 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) #给新表的个列添加对应的数据
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)模块获取手机号归属地、区号、运营商等的更多相关文章

  1. python3.4学习笔记(二十三) Python调用淘宝IP库获取IP归属地返回省市运营商实例代码

    python3.4学习笔记(二十三) Python调用淘宝IP库获取IP归属地返回省市运营商实例代码 淘宝IP地址库 http://ip.taobao.com/目前提供的服务包括:1. 根据用户提供的 ...

  2. C#根据淘宝接口网址获取客户端访问IP和网络运营商

    网络运营商会为每台联网的电脑分配公网IP,如何获取它们?? 话不多说直接上代码: using System; using System.Collections.Generic; using Syste ...

  3. python wmi模块 获取windows内部信息

    WMI (Windows Management Instrumentation) 模块可用于获取 Windows 内部信息,在使用Python获取Windows系统上的相关的信息可以使用WMI接口来获 ...

  4. python random模块(获取随机数)

    如果要使用random模块,需要先导入 import random 1.random.random()  #用于生成一个0到1的随机浮点数 2.random.uniform(a,b)  #用于生成一个 ...

  5. Python random模块 获取随机数的使用

    random.randomrandom.random()用于生成一个0到1的随机符点数: 0 <= n < 1.0 random.uniformrandom.uniform(a, b),用 ...

  6. java获取手机号归属地

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import ...

  7. mysql python pymysql模块 获取插入的最后一条数据的自增ID lastrowid()方法

    调用游标下的lastrowid 可以获取插入之前的表里id字段存放到哪个自增id cursor.lastrowid mysql> select * from userinfo; +----+-- ...

  8. python os模块获取指定目录下的文件列表

    bath_path = r"I:\ner_results\ner_results" dir_list1 = os.listdir(bath_path) for dir1 in di ...

  9. PHP 判断手机号归属地 和 运营商的免费接口

    在项目开发的时候,需要去查询又一批手机号或者固话的具体信息(归属地 运营商) 就需要写一个脚本,来批量请求接口来得到我们想要的数据 学习源头:https://blog.csdn.net/shaerdo ...

随机推荐

  1. ubuntu18.04安装chromium浏览器

    sudo add-apt-repository ppa:a-v-shkop/chromium sudo apt-get upate sudo apt-get install chromium-brow ...

  2. cisco 各类子网的划分

    C类地址子网划分 /25 子网掩码为128: 1位的取值为1,其他7位的取值为0(10000000): 块大小128: (256-128): 2个子网,每个子网最多包含126台主机: /26 子网掩码 ...

  3. 最新 中手游java校招面经 (含整理过的面试题大全)

    从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.中手游等10家互联网公司的校招Offer,因为某些自身原因最终选择了中手游.6.7月主要是做系统复习.项目复盘.LeetCo ...

  4. input标签自动填充问题

    <input type='text' placeholder='手机号' /> <input type='text' placeholder='地址' /> <input ...

  5. ul根据后台添加li,并在点击li时,颜色随之变化

    在我们大多数时候都是通过<ul><li>...</li></ul>来实现同级的加载,但是也用很多时候li里的内容是不固定的.需要根据后台返回数据来生成. ...

  6. FineReport做成之后如何在Tomcat上运行

    问题描述: 自己用FineReport做成的报表画面,要在Tomcat上运行启动 第一步:下载Tomcat 网址: http://tomcat.apache.org/download-80.cgi 下 ...

  7. hadoop在eclipse当中如何添加源码?

    [学习笔记] /*org.apache.hadoop.mapreduce.Mapper.Context,java.lang.InterruptedException,想看map的源代码,按contro ...

  8. Python 实现把两个排好序的的列表合并成一个排序列表

    列表是升序的 # -*- coding: utf-8 -*- # 合并两个排序的数组 def merge_list(a, b): if not a: return b if not b: return ...

  9. Python基础 第6章 抽象

    1. 引言及抽象和结构 生成斐波那契数列的代码如下: fibs = [0, 1] num = int(input('How many num you want:')) for x in range(n ...

  10. Ettercap 帮助文档

    Ettercap(8)帮助 (翻译来自百度翻译,原文附于文后,个人润色) 1.概述 Ettercap-多用途嗅探器/内容过滤器,用于中间人攻击 重要提示 自Ettercap Ng(以前为0.7.0)以 ...