🏝️💻

This commit is contained in:
Casper V. Kristensen 2024-08-04 23:40:46 +02:00
parent 44b050e0aa
commit e05e136287

52
main.py
View file

@ -1,15 +1,36 @@
import asyncio import asyncio
import webbrowser from asyncio import Lock
from time import time
import certstream import certstream
import httpx import httpx
from selenium import webdriver
from termcolor import colored from termcolor import colored
client = httpx.AsyncClient() client = httpx.AsyncClient()
semaphore = asyncio.Semaphore(10) semaphore = asyncio.Semaphore(10)
lock = Lock()
last_open_time = 0
driver = webdriver.Firefox()
driver.set_page_load_timeout(9)
cringe = {
"parkingcrew.net",
"sale_banner",
"sellerratings",
"website coming soon",
"parked",
"parking",
"domain",
"related searches",
"/lander",
"window.park",
"sorry, site could not be found",
}
already_shown = set()
async def handler(message: dict, context: dict) -> None: async def handler(message: dict, context: dict) -> None:
global last_open_time
if message["message_type"] != "certificate_update": if message["message_type"] != "certificate_update":
return return
@ -19,21 +40,46 @@ async def handler(message: dict, context: dict) -> None:
except StopIteration: except StopIteration:
return return
if "cpanel" in domain:
return
url = f"https://{domain}" url = f"https://{domain}"
try: try:
async with semaphore: async with semaphore:
r = await client.head(url, timeout=1) headers = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",
}
r = await client.get(url, timeout=5, headers=headers)
except httpx.HTTPError: except httpx.HTTPError:
print(colored("???", on_color="on_dark_grey"), domain) print(colored("???", on_color="on_dark_grey"), domain)
return return
try:
r.json()
return
except:
1337
if len(r.text) == 0:
return
# TODO: performance
if any(c in r.text.lower() for c in cringe):
return
if r.status_code != 200: if r.status_code != 200:
print(colored(str(r.status_code), on_color="on_yellow"), domain) print(colored(str(r.status_code), on_color="on_yellow"), domain)
return return
print(colored(str(r.status_code), on_color="on_cyan"), domain) print(colored(str(r.status_code), on_color="on_cyan"), domain)
webbrowser.open_new_tab(url) async with lock:
if last_open_time + 10 < time():
if r.text in already_shown:
return
already_shown.add(r.text)
last_open_time = time()
driver.get(url)
async def main() -> None: async def main() -> None: