with open("inn.txt") as file:
inn = file.read().splitlines()
for i in inn:
url = f"https://excheck.pro/company/"+i+"/contacts/edit"
print(url)
r = requests.get(url)
r.text
soup = BeautifulSoup(r.text, "lxml")
for name in soup.select("body > main > div > blockquote > div.fw-bold > a"):
name = name.text
for phone in soup.select("#organization-contacts > div:nth-child(2) > textarea"):
phone = phone.text
try:
for email in soup.select("#organization-contacts > div:nth-child(3) > textarea"):
email = email.text
except:
email = print("none")
try:
for website in soup.select("#organization-contacts > div:nth-child(4) > input"):
website = website.get("value")
except:
website = None
with open("result.csv", "w", encoding="UTF-8") as file:
writer = csv.writer(file)
writer.writerow(
(
"Имя компании",
"Инн",
"email",
"Телефон",
"Сайт"
)
)
with open("result.csv", "a", encoding="UTF-8") as file:
writer = csv.writer(file)
writer.writerow(
(
name,
i,
email,
phone,
website
)
)
with open("result.csv", "w", encoding="UTF-8") as file:
writer = csv.writer(file)
writer.writerow(
(
"Имя компании",
"Инн",
"email",
"Телефон",
"Сайт"
)
)
with open("result.csv", "a", encoding="UTF-8") as file:
writer = csv.writer(file)
writer.writerow(
(
name,
i,
email,
phone,
website
)
)