Neuer Ansatz für den Wettkampfsammler

Changes to be committed:
- kleinere Korrekturen/Verbesserungen
	modified:   homepage/redesign2018/markdownExperiment/Makefile
	modified:   homepage/redesign2018/markdownExperiment/src/jsonSd/cwsvJudo.json
- Neuer Ansatz für den Wettkampfsammler
	new file:   wkOrg/src/wkScraper/scrapyDocAuthorSpider.py
	new file:   wkOrg/src/wkScraper/scrapyDocQuoteSpider.py
	new file:   wkOrg/src/wkScraper/scrapyJvsKalender.py
This commit is contained in:
marko
2018-09-20 14:38:52 +02:00
parent 3ef14f9998
commit 8af477fca8
5 changed files with 90 additions and 5 deletions

View File

@@ -0,0 +1,26 @@
import scrapy
class AuthorSpider(scrapy.Spider):
name = 'author'
start_urls = ['http://quotes.toscrape.com/']
def parse(self, response):
# follow links to author pages
for href in response.css('.author + a::attr(href)'):
yield response.follow(href, self.parse_author)
# follow pagination links
for href in response.css('li.next a::attr(href)'):
yield response.follow(href, self.parse)
def parse_author(self, response):
def extract_with_css(query):
return response.css(query).extract_first().strip()
yield {
'name': extract_with_css('h3.author-title::text'),
'birthdate': extract_with_css('.author-born-date::text'),
'bio': extract_with_css('.author-description::text'),
}