-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (25 loc) · 882 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import asyncio
from pydoll.browser.chrome import Chrome
import json
def format_url(company) -> str:
cnpj = company["cnpj"]
razao_social = company["razao_social"]
param = (
"-".join(razao_social.lower().replace("&", "and").replace(",", "").split(" "))
+ "-"
+ cnpj
)
return "https://casadosdados.com.br/solucao/cnpj/" + param
async def main(url_list: list[str]):
async with Chrome() as browser:
await browser.start()
page = await browser.get_page()
for url in url_list:
print(f'acessando {url}')
await page.go_to(url)
if __name__ == '__main__':
with open('lista.json', mode='r') as js:
js_obj = json.load(js)
url_list: list[str] = [format_url(x) for x in js_obj]
print(f'quantidade de urls = {len(url_list)}')
asyncio.run(main(url_list))