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

class AdvancedUserRecipe1675504328(BasicNewsRecipe):
    title          = 'Google news-ceshi'
    oldest_article = 1
    max_articles_per_feed = 100
    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          = [
        ('"ASML" - Google News', 'https://news.google.com/news/rss/search?q=ASML&hl=en'),
        ('"intel" - Google News', 'https://news.google.com/news/rss/search?q=intel&hl=en'),
        ('amazon - Google News', 'http://news.google.com/news?hl=en&gl=us&q=amazon&um=1&ie=UTF-8&output=rss'),
        ('Ubuntu - Google News', 'http://news.google.com/news?hl=en&gl=us&q=Ubuntu&um=1&ie=UTF-8&output=rss'),
    ]