Last active
November 13, 2022 16:04
-
-
Save korayal/49115297ae7dc13e6caaa25d3d666978 to your computer and use it in GitHub Desktop.
Netblocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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