Skip to content

Instantly share code, notes, and snippets.

@nix2intel
Created July 29, 2023 04:10
Show Gist options
  • Save nix2intel/9596842b9f45617ccc67c251932f1971 to your computer and use it in GitHub Desktop.
Save nix2intel/9596842b9f45617ccc67c251932f1971 to your computer and use it in GitHub Desktop.
Download Hunchly Daily Report with Playwright
import os
from playwright.sync_api import Playwright, sync_playwright, expect
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=True)
context = browser.new_context()
page = context.new_page()
page.goto("https://www.dropbox.com/s/dvm23v5dhoe1cz4/HiddenServices.xlsx?dl=0")
with page.expect_download() as download_info:
page.click("button:has-text('Download')")
download_info.value # Wait for the download event
download_path = download_info.value.path()
# Move the downloaded file to a desired location (optional)
target_path = os.path.join(".", "HiddenServices.xlsx")
os.rename(download_path, target_path)
# ---------------------
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment