Python 查询固定电话位置
Python 查询固定电话位置from requests import get
from bs4 import BeautifulSoup as BS
def open_url(url):
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'}
res = get(url, headers = headers)
return res
def get_phone(res):
soup = BS(res.text, "html.parser")
target = soup.find_all("td", bgcolor="#FFFFFF", style="font-size:16px;")
print("电话号码:" + target.text)
print("归属地: " + target.text)
def main():
while True:
phone = input("请输入电话号码(输入的格式如:010-86551122 或 01086551122): ")
if phone == "Q!":
break
url = 'https://tel.51240.com/%s__tel/' % phone
res = open_url(url)
get_phone(res)
if __name__ == "__main__":
main() 楼主,电话号格式可以用移动电话的吗? 战神赤鼬 发表于 2020-4-2 13:38
楼主,电话号格式可以用移动电话的吗?
目前不行,我现在再写一个 战神赤鼬 发表于 2020-4-2 13:38
楼主,电话号格式可以用移动电话的吗?
写好了,你去看吧
页:
[1]