mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-04 11:45:00 +00:00
Install Chromium if not already installed before launching it.
This commit is contained in:
parent
09de0f5d43
commit
5a06508e0e
1 changed files with 3 additions and 6 deletions
9
playw.py
9
playw.py
|
@ -4,17 +4,14 @@ from playwright.__main__ import main as playwright_install
|
||||||
|
|
||||||
def main(url):
|
def main(url):
|
||||||
# Check if Chromium is installed, if not, install it
|
# Check if Chromium is installed, if not, install it
|
||||||
try:
|
with sync_playwright() as p:
|
||||||
with sync_playwright() as p:
|
p.chromium.launch()
|
||||||
p.chromium.launch()
|
|
||||||
except Exception as e:
|
|
||||||
print("Chromium is not installed. Installing necessary dependencies...")
|
|
||||||
playwright_install(['install', 'chromium'])
|
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
browser = p.chromium.launch()
|
browser = p.chromium.launch()
|
||||||
page = browser.new_page()
|
page = browser.new_page()
|
||||||
page.goto(url)
|
page.goto(url)
|
||||||
|
#page.wait_for_load_state('networkidle')
|
||||||
content = page.content()
|
content = page.content()
|
||||||
print(content)
|
print(content)
|
||||||
browser.close()
|
browser.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue