Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update method names #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update method names
  • Loading branch information
AnthonyChouGit committed Oct 21, 2019
commit b2f38791372acbf9b8e2e87c23acceffb9a1aac2
8 changes: 4 additions & 4 deletions quotesbot/spiders/toscrape-css.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class ToScrapeCSSSpider(scrapy.Spider):
def parse(self, response):
for quote in response.css("div.quote"):
yield {
'text': quote.css("span.text::text").extract_first(),
'author': quote.css("small.author::text").extract_first(),
'tags': quote.css("div.tags > a.tag::text").extract()
'text': quote.css("span.text::text").get(),
'author': quote.css("small.author::text").get(),
'tags': quote.css("div.tags > a.tag::text").getall()
}

next_page_url = response.css("li.next > a::attr(href)").extract_first()
next_page_url = response.css("li.next > a::attr(href)").get()
if next_page_url is not None:
yield scrapy.Request(response.urljoin(next_page_url))

8 changes: 4 additions & 4 deletions quotesbot/spiders/toscrape-xpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class ToScrapeSpiderXPath(scrapy.Spider):
def parse(self, response):
for quote in response.xpath('//div[@class="quote"]'):
yield {
'text': quote.xpath('./span[@class="text"]/text()').extract_first(),
'author': quote.xpath('.//small[@class="author"]/text()').extract_first(),
'tags': quote.xpath('.//div[@class="tags"]/a[@class="tag"]/text()').extract()
'text': quote.xpath('./span[@class="text"]/text()').get(),
'author': quote.xpath('.//small[@class="author"]/text()').get(),
'tags': quote.xpath('.//div[@class="tags"]/a[@class="tag"]/text()').getall()
}

next_page_url = response.xpath('//li[@class="next"]/a/@href').extract_first()
next_page_url = response.xpath('//li[@class="next"]/a/@href').get()
if next_page_url is not None:
yield scrapy.Request(response.urljoin(next_page_url))