-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into cntx-restore
# Conflicts: # scrapypuppeteer/middleware.py
- Loading branch information
Showing
25 changed files
with
272 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Ruff Code Check | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
ruff: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: Install Ruff | ||
run: | | ||
pip install ruff | ||
- name: Run Ruff Format | ||
run: | | ||
ruff format --check | ||
- name: Run Ruff Check | ||
run: | | ||
ruff check . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from logging import ERROR | ||
|
||
import scrapy | ||
from scrapy.utils.log import failure_to_exc_info | ||
from twisted.python.failure import Failure | ||
|
||
from scrapypuppeteer import ( | ||
PuppeteerRequest, | ||
PuppeteerResponse, | ||
PuppeteerScreenshotResponse, | ||
) | ||
from scrapypuppeteer.actions import Click, Compose, GoTo, Screenshot, Scroll | ||
|
||
|
||
class ComposeSpider(scrapy.Spider): | ||
name = "compose" | ||
|
||
custom_settings = { | ||
"DOWNLOADER_MIDDLEWARES": { | ||
"scrapypuppeteer.middleware.PuppeteerServiceDownloaderMiddleware": 1042, | ||
}, | ||
} | ||
|
||
def start_requests(self): | ||
goto = GoTo("https://pptr.dev") | ||
click_1 = Click( | ||
"#__docusaurus > nav > div.navbar__inner > div:nth-child(1) > a:nth-child(3)" | ||
) | ||
click_2 = Click( | ||
"#__docusaurus_skipToContent_fallback > div > div > aside > div > " | ||
"div > nav > ul > li:nth-child(1) > ul > li:nth-child(3) > a" | ||
) | ||
click = Compose(click_1, click_2) | ||
scroll = Scroll() | ||
screenshot = Screenshot(options={"full_page": True, "type": "jpeg"}) | ||
|
||
compose_action = Compose( | ||
goto, | ||
click, | ||
scroll, | ||
screenshot, | ||
) | ||
|
||
yield PuppeteerRequest( | ||
compose_action, | ||
callback=self.parse, | ||
errback=self.errback, | ||
close_page=True, | ||
) | ||
|
||
def parse(self, response: PuppeteerResponse): | ||
assert isinstance(response, PuppeteerScreenshotResponse) | ||
self.log("Spider worked fine!") | ||
|
||
def errback(self, failure: Failure): | ||
print(failure) | ||
self.log(failure_to_exc_info(failure), level=ERROR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import scrapy | ||
|
||
from scrapypuppeteer import PuppeteerRequest | ||
from scrapypuppeteer.actions import Har | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[tool.ruff] | ||
line-length = 88 | ||
fix = false | ||
indent-width = 4 | ||
|
||
[tool.ruff.lint] | ||
select = ["F", "C", "W", "I"] | ||
ignore = ["E203", "E501", "F401", "C408", "F811", "N807"] | ||
|
||
[tool.ruff.format] | ||
indent-style = "space" | ||
line-ending = "auto" | ||
quote-style = "double" | ||
skip-magic-trailing-comma = false | ||
docstring-code-line-length = 88 | ||
docstring-code-format = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
from .actions import ( | ||
PuppeteerServiceAction, | ||
GoTo, | ||
GoForward, | ||
GoBack, | ||
Click, | ||
Scroll, | ||
Screenshot, | ||
Har, | ||
CustomJsAction, | ||
FillForm, | ||
GoBack, | ||
GoForward, | ||
GoTo, | ||
Har, | ||
PuppeteerServiceAction, | ||
RecaptchaSolver, | ||
CustomJsAction, | ||
Screenshot, | ||
Scroll, | ||
) | ||
from .request import PuppeteerRequest, CloseContextRequest | ||
from .request import CloseContextRequest, PuppeteerRequest | ||
from .response import ( | ||
PuppeteerResponse, | ||
PuppeteerHtmlResponse, | ||
PuppeteerScreenshotResponse, | ||
PuppeteerRecaptchaSolverResponse, | ||
PuppeteerJsonResponse, | ||
PuppeteerRecaptchaSolverResponse, | ||
PuppeteerResponse, | ||
PuppeteerScreenshotResponse, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.