scrapy-plugins / scrapy-playwright

🎭 Playwright integration for Scrapy
BSD 3-Clause "New" or "Revised" License
1.03k stars 113 forks source link

How to use playwright-stealth ? #245

Closed josearodrigueze closed 1 year ago

elacuesta commented 1 year ago

Assuming you're referring to https://pypi.org/project/playwright-stealth/, it should be possible to do it with https://github.com/scrapy-plugins/scrapy-playwright#playwright_page_init_callback. I haven't tested it myself, but something like this:

from playwright_stealth import stealth_async

async def init_page(page, request):
    await stealth_async(page)

class StealthSpider(scrapy.Spider):
    name = "stealth"

    def start_requests(self):
        yield scrapy.Request(
            url="https://example.org",
            meta={
                "playwright": True,
                "playwright_page_init_callback": init_page,
            },
        )
josearodrigueze commented 1 year ago

It works perfect thanks for the help. I really appreciate your help, have a great day.