qiuyouzhi 发表于 2020-3-31 15:54:38

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_Info(res):
    soup = BS(res.text, "html.parser")
    target = soup.find("td")
    print(target.text)

def main():
    while True:
      id1 = input("请输入身份证号码:")
      if id1 == "Q!":
            break
      url = 'https://shenfenzheng.51240.com/%s__shenfenzheng/' % id1
      res = open_url(url)
      get_Info(res)

if __name__ == "__main__":
    main()

很丑,但可以美观(find_all找出td,然后分类打印,
不过我懒得搞,能用,看的见就行)

Funky_KAK 发表于 2020-3-31 16:40:00

{:10_257:}

龙舞九天 发表于 2021-5-31 14:54:35

{:5_95:}
页: [1]
查看完整版本: Python 查询身份证号码信息