Skip to content

Instantly share code, notes, and snippets.

@korayal
Last active November 13, 2022 16:04
Show Gist options
  • Save korayal/49115297ae7dc13e6caaa25d3d666978 to your computer and use it in GitHub Desktop.
Save korayal/49115297ae7dc13e6caaa25d3d666978 to your computer and use it in GitHub Desktop.
Netblocks
#
# First install python-playwright via: `pip3 install playwright && playwright install`
#
from playwright.sync_api import sync_playwright
from datetime import datetime, timedelta
import time
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.goto('https://api.webprobe.org/scan/')
done = False
starttime = datetime.utcnow()
while not done:
content = page.content()
report_complete = page.is_visible('div#probe_report')
timeout = (datetime.utcnow() - starttime) > timedelta(seconds=60)
if report_complete or timeout:
done = True
else:
time.sleep(1)
browser.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment