-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (27 loc) · 1.31 KB
/
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
31
32
33
34
35
36
import requests
from bs4 import BeautifulSoup
from tqdm import tqdm
def process_url(url):
response = requests.get(url)
if response.status_code == 200:
soup = BeautifulSoup(response.text, 'html.parser')
meta_tag = soup.select_one("head > meta:nth-child(13)")
if meta_tag:
content_value = meta_tag.get("content")
else:
content_value = "Мета-тег не найден."
else:
content_value = f"Ошибка при получении страницы. Статус код: {response.status_code}"
return content_value
def main():
with open("urls.txt", "r") as file:
urls = file.read().splitlines()
with open("contract.txt", "w") as output_file, open("list.txt", "w") as list_file:
contract_addresses = [] # Список для хранения всех контрактов
for url in tqdm(urls, desc="Собираю контракты", unit="URL", bar_format="{l_bar}{bar}{r_bar}", colour="green"):
result = process_url(url)
output_file.write(f"{url}: {result}\n")
contract_addresses.extend(result.split(", "))
list_file.write(",\n".join(['"' + address + '"' for address in contract_addresses]) + "\n")
if __name__ == "__main__":
main()