#!/usr/bin/env python
# vim:fileencoding=utf-8
from calibre.web.feeds.news import BasicNewsRecipe
from calibre import browser
from calibre.ptempfile import PersistentTemporaryFile

class AdvancedUserRecipe1675596949(BasicNewsRecipe):
    title          = 'N001-economic'
    oldest_article = 1
    max_articles_per_feed = 1000000
    auto_cleanup   = True
    
    articles_are_obfuscated = True
    
    def get_obfuscated_article(self, url):
        br = self.get_browser()
        try:
            br.open(url)
        except Exception as e:
            url = e.hdrs.get('location')
        soup = self.index_to_soup(url)
        link = soup.find('a', href=True)
        html = br.open(link['href']).read()
        pt = PersistentTemporaryFile('.html')
        pt.write(html)
        pt.close()
        return pt.name

    feeds          = [
        ('Deutsche Wirtschaft - Google News', 'https://news.google.com/news/rss/search?q=Deutsche Wirtschaft&hl=de'),
        ('Energie - Google News', 'https://news.google.com/news/rss/search?q="Energie"&hl=de'),
        ('E-Autos - Google News', 'https://news.google.com/news/rss/search?q="E-Autos"&hl=de'),
    ]