36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import requests
|
|
import threading
|
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
from lxml import etree
|
|
from faker import Faker
|
|
|
|
executor = ThreadPoolExecutor(max_workers=10)
|
|
faker = Faker(["zh_CN"])
|
|
|
|
|
|
def faker_identification():
|
|
identification = faker.ssn(max_age=70)
|
|
resp = requests.get("https://shenfenzheng.bmcx.com/" + identification + "__shenfenzheng/")
|
|
html = etree.HTML(resp.text)
|
|
infos = html.xpath('//table[@width="100%"]//tr[position()!=2]/td[@bgcolor="#FFFFFF"]//text()')
|
|
result = {
|
|
'identification': infos[0],
|
|
'originArea': infos[1],
|
|
'sex': infos[3][0],
|
|
'name': faker.last_name() + (faker.first_name_male() if infos[3][0] == '男' else faker.first_name_female()),
|
|
'age': infos[4][0:-2]
|
|
}
|
|
return result
|
|
|
|
|
|
def time(times):
|
|
return times
|
|
|
|
|
|
def faker_identifications(num: int):
|
|
all_tasks = [executor.submit(faker_identification) for i in range(num)]
|
|
results = []
|
|
for future in as_completed(all_tasks):
|
|
results.append(future.result())
|
|
return results
|