当我运行脚本时,它启动了 2 个浏览器,但我只需要 1 个浏览器实例,我怎样才能得到它
import time
from playwright.sync_api import sync_playwright
def run():
"""Open betway.com"""
with sync_playwright() as p:
browser = p.firefox.launch(
user_data_dir="C:\\Users\\cocacola\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\bot_new",
headless=False,
slow_mo=50,
args=["--no-sandbox"],
)
page = browser.new_page()
page.set_viewport_size({"width": 1200, "height": 720})
# context = browser.new_context()
# context.tracing.start(screenshots=True, snapshots=True)
def navigate():
"""Navigate in browser"""
print("[*] Go to google.com.")
page.goto("https://google.com")
print("[*] Waiting for page loading.")