|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
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,然后分类打印,
不过我懒得搞,能用,看的见就行) |
|