Код: Выделить всё
import scrapy
from scrapy_playwright.page import PageMethod
class DownloadSpider(scrapy.Spider):
name = "download"
def start_requests(self):
yield scrapy.Request(
url="https://the-internet.herokuapp.com/download",
meta=dict(
playwright=True,
playwright_include_page = True,
),
)
async def parse(self, response):
page = response.meta["playwright_page"]
async with page.expect_download() as download_info:
await page.get_by_text("lm-login.txt").click()
download = await download_info.value
await download.save_as(download.suggested_filename)
Код: Выделить всё
"in save_as
file = await self._loop.run_in_executor(None, lambda: open(path, "wb"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"RuntimeError: Task
Подробнее здесь: [url]https://stackoverflow.com/questions/79028556/simple-download-on-click-with-scrapy-playwright[/url]