是否可以在 Scrapy shell 中调用 Playwright?
我想使用 shell 来测试我的 xpath,我打算将其放置在包含 Scrapy Playwright 的蜘蛛中。
我的 scrapy 设置文件具有通常的 Playwright 设置:
# Scrapy Playwright Setup
DOWNLOAD_HANDLERS = {
"http": "scrapy_playwright.handler.ScrapyPlaywrightDownloadHandler",
"https": "scrapy_playwright.handler.ScrapyPlaywrightDownloadHandler",
}
TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"
最佳答案
是的,这是可能的。事实上,您所要做的就是在包含 scrapy 项目的文件夹中运行 scrapy shell。它将自动从 settings.py 加载所有默认设置。运行 scrapy shell 时可以在日志中看到它。
此外,您还可以使用 -s
参数覆盖设置。
scrapy shell -s DOWNLOAD_HANDLERS='<<your custom handlers>>'
祝你抓取愉快:)
关于web-scraping - Scrapy shell 与剧作家,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72555810/