-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (27 loc) · 989 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
31
32
33
34
35
36
import random
from rich import print
from rich.panel import Panel
import asyncio
import aiofiles
import validators
import argparse
from checker import checker
parser = argparse.ArgumentParser(description='linkchecker')
parser.add_argument('--filein', type=str, help='.txt file with links')
parser.add_argument('--fileout', type=str, help='.txt file where output should be saved')
parser.add_argument('--proxies', type=str, help='.txt file with proxies')
args = parser.parse_args()
filein = args.filein
fileout = args.fileout
proxies = open(args.proxies, 'r').readlines()
async def main():
async with aiofiles.open(filein, mode='r') as links:
async for link in links:
if validators.url(link):
proxy = random.choice(proxies)
print(Panel.fit(f"Использую прокси: {proxy}"))
await checker(link, fileout, proxy)
else:
print(Panel.fit(f"[red]Ссылка введена неверно: {link}[/]"))
if __name__ == "__main__":
asyncio.run(main())