Last active
August 20, 2023 20:27
-
-
Save dacxjo/3028f841b207d2a607d8da725350a349 to your computer and use it in GitHub Desktop.
Playwright python web visits script
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
""" | |
Simple script to browse an <url> and reload the visited page | |
a given number of <iterations>. | |
""" | |
from playwright.sync_api import sync_playwright | |
import sys | |
def main(): | |
if len(sys.argv) != 3: | |
print("Usage: python main.py <url> <iterations>") | |
sys.exit(1) | |
url = sys.argv[1] | |
iterations = sys.argv[2] | |
with sync_playwright() as p: | |
browser = p.chromium.launch() | |
page = browser.new_page() | |
page.goto(url) | |
for i in range(int(iterations)): | |
page.reload() | |
browser.close() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment