import scrapy

from feeds.loaders import FeedEntryItemLoader
from feeds.spiders import FeedsSpider


class VerbraucherrechtAtSpider(FeedsSpider):
    name = 'verbraucherrecht.at'
    allowed_domains = ['verbraucherrecht.at']
    start_urls = ['https://verbraucherrecht.at/cms/index.php?id=198']

    _title = 'Verbraucherrecht'
    _subtitle = 'Neuigkeiten rund um Konsumentenschutz und Verbraucherrechte'
    _author_name = 'Verein für Konsumenteninformation'
    _link = 'https://{}'.format(name)
    _logo = ('https://{}/cms/fileadmin/imag/logo.gif'.format(name))
    _timezone = 'Europe/Vienna'

    def parse(self, response):
        # Fetch only the current news page and deliberately ignore old news.
        for link in response.xpath(
                '//div[@class="news-list-container"]//h2/a/@href').extract():
            yield scrapy.Request(response.urljoin(link), self.parse_item)

    def parse_item(self, response):
        il = FeedEntryItemLoader(
            response=response,
            base_url='{}/cms/'.format(self._link),
            timezone=self._timezone,
            remove_elems=['font'])

        il.add_value(
            'title',
            response.xpath('//head/title/text()').re_first(r'::: (.*)'))

        il.add_value('link', response.url)

        il.add_value(
            'updated',
            response.xpath('//div[@class="news-single-rightbox"]').
            re_first(r'(\d{2}\.\d{2}\.\d{4})'))

        il.add_value(
            'author_name',
            response.xpath('//head/meta[@name="publisher"]/@content').
            re_first('recht.at, (.*);'))
        il.add_xpath('author_name', '//head/meta[@name="author"]/@content')
        il.add_value('author_name', self.name)

        il.add_xpath('author_email', '//head/meta[@name="reply-to"]/@content')

        il.add_xpath('content_html', '//div[@class="news-single-item"]/h7')
        il.add_xpath('content_html', '//div[@class="news-single-item"]/p')
        il.add_xpath(
            'content_html', '//div[@class="news-single-additional-info"]')
        yield il.load_item()

# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 smartindent autoindent

@@ -1110,14 +1110,248 @@
 s=%5B'
-font'%5D
+.news-latest-date', '.news-single-rightbox', 'hr',%0A                          'h7'%5D,%0A            remove_elems_xpath=%5B'//div%5B@class=%22news-single-item%22%5D/b%5B1%5D',%0A                                '//div%5B@class=%22news-single-item%22%5D/br%5B1%5D'%5D,%0A        
 )%0A%0A 
@@ -2044,37 +2044,35 @@
 %0A        il.add_
-xpath
+css
 ('content_html',
@@ -2069,38 +2069,25 @@
 ent_html', '
-//div%5B@class=%22
+.
 news-single-
@@ -2094,188 +2094,83 @@
 item
-%22%5D/h7')%0A        il.add_xpath('content_html', '//div%5B@class=%22news-single-item%22%5D/p')%0A        il.add_xpath(%0A            'content_html', '//div%5B@class=%22news-single-additional-info%22%5D
+ h7 font strong')%0A        il.add_css('content_html', '.news-single-item
 ')%0A
+%0A
     

Fix content extraction.