diff --git a/scrapypuppeteer/browser_managers/browser_downloader_handler.py b/scrapypuppeteer/browser_managers/browser_downloader_handler.py index 3695561..a692ab3 100644 --- a/scrapypuppeteer/browser_managers/browser_downloader_handler.py +++ b/scrapypuppeteer/browser_managers/browser_downloader_handler.py @@ -1,7 +1,7 @@ +from scrapy import signals from scrapy.core.downloader.handlers.http import HTTPDownloadHandler from scrapy.crawler import Crawler from scrapy.utils.reactor import verify_installed_reactor -from scrapy import signals from twisted.internet.defer import Deferred from scrapypuppeteer import CloseContextRequest diff --git a/scrapypuppeteer/browser_managers/playwright_browser_manager.py b/scrapypuppeteer/browser_managers/playwright_browser_manager.py index 028c46e..d4c43d3 100644 --- a/scrapypuppeteer/browser_managers/playwright_browser_manager.py +++ b/scrapypuppeteer/browser_managers/playwright_browser_manager.py @@ -1,15 +1,15 @@ import asyncio import base64 import uuid -from typing import Dict, Callable, Awaitable, Union from dataclasses import dataclass +from typing import Awaitable, Callable, Dict, Union -from playwright.async_api import async_playwright, Browser, BrowserContext, Page +from playwright.async_api import Browser, BrowserContext, Page, async_playwright from scrapy.http import TextResponse -from scrapypuppeteer import PuppeteerResponse, PuppeteerRequest +from scrapypuppeteer import PuppeteerRequest, PuppeteerResponse from scrapypuppeteer.browser_managers import BrowserManager -from scrapypuppeteer.request import CloseContextRequest, ActionRequest +from scrapypuppeteer.request import ActionRequest, CloseContextRequest from scrapypuppeteer.response import ( PuppeteerHtmlResponse, PuppeteerScreenshotResponse, @@ -50,7 +50,9 @@ async def open_new_page(self): page_id = uuid.uuid4().hex.upper() self.contexts[context_id] = await self.browser.new_context() - self.pages[page_id] = BrowserPage(context_id, page_id, await self.contexts[context_id].new_page()) + self.pages[page_id] = BrowserPage( + context_id, page_id, await self.contexts[context_id].new_page() + ) self.context2page[context_id] = page_id return context_id, page_id