Skip to content

Commit

Permalink
Better example
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewZMSU committed Sep 26, 2024
1 parent 39e2107 commit c999ef2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/spiders/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
PuppeteerResponse,
PuppeteerScreenshotResponse,
)
from scrapypuppeteer.actions import Click, Compose, GoTo, Screenshot
from scrapypuppeteer.actions import Click, Compose, GoTo, Screenshot, Scroll


class ComposeSpider(scrapy.Spider):
Expand All @@ -19,6 +19,7 @@ class ComposeSpider(scrapy.Spider):
"DOWNLOADER_MIDDLEWARES": {
"scrapypuppeteer.middleware.PuppeteerServiceDownloaderMiddleware": 1042,
},
"EXECUTION_METHOD": "Pyppeteer",
}

def start_requests(self):
Expand All @@ -31,11 +32,13 @@ def start_requests(self):
"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,
)

Expand All @@ -51,4 +54,5 @@ def parse(self, response: PuppeteerResponse):
self.log("Spider worked fine!")

def errback(self, failure: Failure):
print(failure)
self.log(failure_to_exc_info(failure), level=ERROR)

0 comments on commit c999ef2

Please sign in to comment.