Created
December 28, 2016 18:27
-
-
Save gfreivasc/fad1c409d6ae9fdff07b8a61dca410d8 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
| import scrapy | |
| class PageLinkItem(scrapy.Item): | |
| title = scrapy.Field() | |
| links = scrapy.Field() | |
| class LinkReaderSpider(scrapy.Spider): | |
| name = 'link_reader' | |
| start_urls = ['http://gabrielfv.com'] | |
| def parse(self, response): | |
| data = PageLinkItem() | |
| data['title'] = response.css('title::text').extract_first() | |
| links = response.css('a') | |
| data['links'] = [ | |
| link.xpath('./@href').extract_first() for link in links | |
| ] | |
| return data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment