Skip to content

Commit

Permalink
Formatting and Unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewZMSU committed Aug 15, 2024
1 parent 6749b0e commit a734a72
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
9 changes: 4 additions & 5 deletions scrapypuppeteer/browser_managers/local_browser_manager.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import asyncio
import base64
import uuid

from pyppeteer import launch
import syncer
import uuid
from pyppeteer import launch

from scrapypuppeteer.response import (
PuppeteerHtmlResponse,
PuppeteerScreenshotResponse,
)
from scrapypuppeteer.request import ActionRequest, PuppeteerRequest, CloseContextRequest

from scrapypuppeteer.request import PuppeteerRequest, CloseContextRequest
from scrapypuppeteer.browser_managers import BrowserManager


Expand Down Expand Up @@ -149,7 +148,7 @@ async def async_click():
cookies = request.cookies
click_options = request.action.click_options or {}
navigation_options = request.action.navigation_options or {}
options = merged = {**click_options, **navigation_options}
options = {**click_options, **navigation_options}
await page.click(selector, options)
wait_options = request.action.payload().get("waitOptions", {}) or {}
await self.wait_with_options(page, wait_options)
Expand Down
8 changes: 1 addition & 7 deletions scrapypuppeteer/browser_managers/service_browser_manager.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import json
import logging
from collections import defaultdict
from typing import List, Union
from urllib.parse import urlencode, urljoin
from abc import ABC, abstractmethod

from scrapy import signals
from scrapy.crawler import Crawler
from scrapy.exceptions import IgnoreRequest, NotConfigured, DontCloseSpider
from scrapy.exceptions import DontCloseSpider
from scrapy.http import Headers, TextResponse, Response
from scrapy.utils.log import failure_to_exc_info
from twisted.python.failure import Failure
Expand All @@ -20,12 +16,10 @@
RecaptchaSolver,
Screenshot,
Scroll,
CustomJsAction,
Har,
FillForm,
)
from scrapypuppeteer.response import (
PuppeteerResponse,
PuppeteerHtmlResponse,
PuppeteerScreenshotResponse,
PuppeteerHarResponse,
Expand Down
11 changes: 4 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

from setuptools import setup, find_packages


def read_long_description(file_path):
with open(file_path, "r") as file:
return file.read()


setup(
name="scrapy-puppeteer-client",
version="0.3.5",
Expand All @@ -16,13 +18,8 @@ def read_long_description(file_path):
author="MODIS @ ISP RAS",
maintainer="Maksim Varlamov",
maintainer_email="[email protected]",
packages=find_packages(),
install_requires=[
"scrapy>=2.6",
"pyppeteer",
"syncer",
"bs4"
],
packages=find_packages(),
install_requires=["scrapy>=2.6", "pyppeteer", "syncer", "bs4"],
python_requires=">=3.6",
license="BSD",
classifiers=[
Expand Down
10 changes: 7 additions & 3 deletions tests/actions/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@


def _gen_goto():
for url, nav_opt, wait_opt, har_recording in product(URLS, NAV_OPTS, WAIT_OPTS, HAR_RECORDING):
for url, nav_opt, wait_opt, har_recording in product(
URLS, NAV_OPTS, WAIT_OPTS, HAR_RECORDING
):
expected = {
"url": url,
"navigationOptions": nav_opt,
"waitOptions": wait_opt,
"harRecording": har_recording
"harRecording": har_recording,
}
yield url, nav_opt, wait_opt, har_recording, expected

Expand Down Expand Up @@ -43,7 +45,9 @@ def _gen_scroll():
yield selector, wait_opt, expected


@mark.parametrize("url, navigation_options, wait_options, har_recording, expected", _gen_goto())
@mark.parametrize(
"url, navigation_options, wait_options, har_recording, expected", _gen_goto()
)
def test_goto(url, navigation_options, wait_options, har_recording, expected):
action = GoTo(url, navigation_options, wait_options, har_recording)
assert action.payload() == expected
Expand Down

0 comments on commit a734a72

Please sign in to comment.