@@ -0,0 +1,2529 @@
+#!/usr/bin/python3%0A%0Afrom scrapy.linkextractors import LinkExtractor%0Afrom scrapy.spiders import CrawlSpider%0Afrom scrapy.spiders import Rule%0A%0Afrom feeds.loaders import FeedEntryItemLoader%0Afrom feeds.loaders import FeedItemLoader%0A%0A%0Aclass MeinbezirkAtSpider(CrawlSpider):%0A    _emitted_feed_item = False%0A%0A    name = %22meinbezirk.at%22%0A    allowed_domains = %5B%22meinbezirk.at%22%5D%0A    start_urls = %5B'http://www.meinbezirk.at/themen/gewinnspiel.html'%5D%0A    rules = (%0A        # Limit to the first 9 pages only, the stuff that follows afterwards is%0A        # most likely expired already.%0A        Rule(LinkExtractor(%0A            allow=('themen/gewinnspiel.html/action/page/%5Cd',),%0A            deny=('themen/gewinnspiel.html/action/page/%5Cd%5Cd+',))),%0A        Rule(LinkExtractor(%0A            restrict_xpaths='//div%5B@id=%22contentArea%22%5D'),%0A            callback='parse_item')%0A    )%0A%0A    def parse_item(self, response):%0A        # Ignore all articles without lottery or with an expired lottery.%0A        if not response.xpath(%0A                '//div%5B@id=%22contentArea%22%5D//text()').re('Jetzt mitmachen'):%0A            return%0A%0A        # One FeedItem is required.%0A        if not self._emitted_feed_item:%0A            self._emitted_feed_item = True%0A            il = FeedItemLoader(response=response)%0A            il.add_value('title', 'Meinbezirk Gewinnspiele')%0A            il.add_value('subtitle', 'Aktuelle Gewinnspiele von Meinbezirk.')%0A            il.add_value('link', self.start_urls%5B0%5D)%0A            il.add_xpath('author_name', '//head/meta%5B@name=%22author%22%5D/@content')%0A            il.add_value('author_name', self.name)%0A            yield il.load_item()%0A%0A        # Parse the actual content.%0A        il = FeedEntryItemLoader(%0A            response=response, datetime_format='%25d.%25m.%25Y, %25H:%25M')%0A        il.add_value('link', response.url)%0A        il.add_xpath('title', '//div%5B@id=%22contentArea%22%5D//h1/text()')%0A        il.add_xpath('title', '//div%5B@id=%22breadcrumbs%22%5D/div/text()')%0A        il.add_xpath('title', '//head/meta%5B@property=%22og:title%22%5D/@content')%0A        il.add_xpath('author_name', '//head/meta%5B@name=%22author%22%5D/@content')%0A        il.add_xpath('author_name', '//head/meta%5B@name=%22publisher%22%5D/@content')%0A        il.add_xpath('updated',%0A                     '//div%5B@class=%22marginBottomS%22%5D/text()', re='(.*) Uhr')%0A        il.add_xpath('content_html', '//section%5B@id=%22articleContent%22%5D')%0A        il.add_xpath('content_html', '//div%5B@id=%22lotteryArea%22%5D/h3//text()')%0A        yield il.load_item()%0A%0A# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 smartindent autoindent%0A

Add meinbezirk.at spider