Last active
March 30, 2017 23:36
-
-
Save tkovs/45ea0eb04e2f926495f4235f7702bd0d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# name: items.py | |
import scrapy | |
class Quote(scrapy.Item): | |
author = scrapy.Field() | |
# name: quotes.py | |
# -*- coding: utf-8 -*- | |
import scrapy | |
from tutorial.items import Quote | |
class Quotes(scrapy.Spider): | |
name = 'quotes' | |
allowed_domains = ['quotes.toscrape.com'] | |
start_urls = [ | |
'http://quotes.toscrape.com/', | |
] | |
def parse(self, response): | |
for quote in response.css('div.quote'): | |
item = Quote() | |
item['author'] = quote.css('small.author::text').extract_first() | |
yield item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment