scrapy-plugins / scrapy-playwright

🎭 Playwright integration for Scrapy
BSD 3-Clause "New" or "Revised" License
992 stars 108 forks source link

How to stop closing browser #234

Open hackerpayne opened 1 year ago

hackerpayne commented 1 year ago

I start one chrome browser at cdp port 40000

i use PLAYWRIGHT_CDP_URL = "http://localhost:40000" in my setting file

but every time scrapy start to work,

it will create new browser,and does't use my openning chrome.

hope someone can help solve this.

In my python code,i use context = browser.contexts[0] if browser.contexts else browser.new_context() page = context.pages[len(context.pages) - 1] if context.pages else context.new_page()

to keep opening in one page to work and keep chrome always running.

elacuesta commented 3 months ago

This is expected, scrapy-playwright will connect and start a context of its own to avoid interfering with other workloads. Unless there's a very strong argument in favor of changing to use the existing context, this will remain the case.