Skip to content

Instantly share code, notes, and snippets.

@tkovs
Last active March 30, 2017 23:36
Show Gist options
  • Save tkovs/45ea0eb04e2f926495f4235f7702bd0d to your computer and use it in GitHub Desktop.
Save tkovs/45ea0eb04e2f926495f4235f7702bd0d to your computer and use it in GitHub Desktop.
# 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