e
This commit is contained in:
parent
8796e2dfc6
commit
00000d9ef1
7 changed files with 318 additions and 44 deletions
|
|
@ -14,6 +14,7 @@ from playwright.async_api import async_playwright
|
|||
from .utils import (
|
||||
TZ,
|
||||
capture_req,
|
||||
firefox,
|
||||
get_base,
|
||||
get_logger,
|
||||
load_cache,
|
||||
|
|
@ -55,9 +56,7 @@ async def refresh_api_cache(
|
|||
|
||||
async def process_event(url: str, url_num: int) -> str | None:
|
||||
async with async_playwright() as p:
|
||||
browser = await p.firefox.launch(headless=True)
|
||||
|
||||
context = await browser.new_context()
|
||||
browser, context = await firefox(p)
|
||||
|
||||
page = await context.new_page()
|
||||
|
||||
|
|
@ -210,11 +209,11 @@ async def main(client: httpx.AsyncClient) -> None:
|
|||
urls[key] = cached_urls[key] = entry
|
||||
|
||||
if new_count := len(cached_urls) - cached_count:
|
||||
CACHE_FILE.write_text(json.dumps(cached_urls, indent=2), encoding="utf-8")
|
||||
|
||||
log.info(f"Collected and cached {new_count} new event(s)")
|
||||
else:
|
||||
log.info("No new events found")
|
||||
|
||||
CACHE_FILE.write_text(json.dumps(cached_urls, indent=2), encoding="utf-8")
|
||||
|
||||
|
||||
# works if no cloudflare bot detection
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue