-
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.
* Follow/follow_all * Documentation * Formatter and linter * Priority fix * Comments * Example and fix * Docstring * Docstring * ban any action except GoTo * fix page_id = None * Add Compose to except * Fix action validation * Fix action validation * Response's state is saved now
- Loading branch information
1 parent
98704eb
commit f41d5fa
Showing
4 changed files
with
129 additions
and
23 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
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,49 @@ | ||
from scrapy import Spider | ||
from scrapy.http import Response | ||
|
||
from scrapypuppeteer import GoTo, PuppeteerRequest, PuppeteerResponse | ||
|
||
|
||
class FollowSpider(Spider): | ||
name = "follow" | ||
|
||
start_urls = ["http://quotes.toscrape.com/page/1/"] | ||
|
||
def start_requests(self): | ||
for url in self.start_urls: | ||
yield PuppeteerRequest( | ||
GoTo(url), | ||
close_page=False, | ||
callback=self.goto_about, | ||
errback=self.errback, | ||
) | ||
|
||
def goto_about(self, response: PuppeteerResponse): | ||
# yield response.follow( | ||
# response.css("div.quote span a")[0], | ||
# callback=self.parse, | ||
# errback=self.errback, | ||
# close_page=False, | ||
# ) | ||
|
||
# Or: | ||
yield from response.follow_all( | ||
response.css("div.quote span a"), | ||
callback=self.parse, | ||
errback=self.errback, | ||
close_page=True, | ||
) | ||
|
||
# Or: | ||
# yield from response.follow_all( | ||
# css="div.quote span a", | ||
# callback=self.parse, | ||
# errback=self.errback, | ||
# close_page=False, | ||
# ) | ||
|
||
def parse(self, response: Response, **kwargs): | ||
self.log(response.url.split("/")[-1]) | ||
|
||
def errback(self, failure): | ||
self.log(failure) |
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