aider/playw.py
Paul Gauthier e2acc028d0 aider: Set the user agent to 'Aider v0.24.0-dev'.
# Aider chat conversation:

USER: set the user agent to 'Aider v0.24.0-dev'

ASSISTANT: ```diff
--- playw.py
+++ playw.py
@@ ... @@
 def main(url):
     # Check if Chromium is installed, if not, install it
     with sync_playwright() as p:
-        p.chromium.launch()
+        browser = p.chromium.launch(user_agent='Aider v0.24.0-dev')
+        page = browser.new_page()
+        page.goto(url)
+        content = page.content()
+        print(content)
+        browser.close()

 if __name__ == "__main__":
     if len(sys.argv) < 2:
```

USER: UnifiedDiffNoMatch: hunk failed to apply!

playw.py does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in playw.py!

playw.py does not contain these 7 exact lines in a row:
```
def main(url):
    # Check if Chromium is installed, if not, install it
    with sync_playwright() as p:
        p.chromium.launch()

if __name__ == "__main__":
    if len(sys.argv) < 2:
```

ASSISTANT: I apologize for the oversight. Here is the corrected diff:

```diff
--- playw.py
+++ playw.py
@@ ... @@
     with sync_playwright() as p:
-        browser = p.chromium.launch()
+        browser = p.chromium.launch(user_agent='Aider v0.24.0-dev')
         page = browser.new_page()
         page.goto(url)
         #page.wait_for_load_state('networkidle')
         content = page.content()
         print(content)
         browser.close()
```
2024-02-08 07:59:12 -08:00

23 lines
682 B
Python

from playwright.sync_api import sync_playwright
import sys
from playwright.__main__ import main as playwright_install
def main(url):
# Check if Chromium is installed, if not, install it
with sync_playwright() as p:
p.chromium.launch()
with sync_playwright() as p:
browser = p.chromium.launch(user_agent='Aider v0.24.0-dev')
page = browser.new_page()
page.goto(url)
#page.wait_for_load_state('networkidle')
content = page.content()
print(content)
browser.close()
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python playw.py <URL>")
sys.exit(1)
main(sys.argv[1])