web-scraping - Scrapy shell 与剧作家

标签 web-scraping scrapy playwright scrapy-shell

是否可以在 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/

相关文章:

python - 如何使用 python selenium find_element_by_xpath 找出上面的关键字

python - 如何使用 Beautifulsoup-python 从 div 内特定标题中的段落元素中提取网页文本

python - 如何在selenium中获取当前选项卡的url?

javascript - 使用带有多个起始 URL 的 selenium 和 Scrapy 抓取动态内容

python - 如何使用python下载推送到浏览器的文件?

java - 如何在 Alpine Docker 容器上运行 Playwright 浏览器测试?

javascript - 在 Azure 函数中运行 Playwright

python - 如何使用 beautifulsoup 和 selenium 在 Python Scraping 中识别类名或 id

javascript - Playwright - beforeEach 用于套件中的所有文件,或对所有测试的模拟响应

python - 如何为通过 socksipy 发出请求的 scrapy 编写 DownloadHandler?