View Single Post
Old 02-04-2023, 05:59 AM   #4
fengli
Zealot
fengli can spell AND pronounce 'liseuse.'fengli can spell AND pronounce 'liseuse.'fengli can spell AND pronounce 'liseuse.'fengli can spell AND pronounce 'liseuse.'fengli can spell AND pronounce 'liseuse.'fengli can spell AND pronounce 'liseuse.'fengli can spell AND pronounce 'liseuse.'fengli can spell AND pronounce 'liseuse.'fengli can spell AND pronounce 'liseuse.'fengli can spell AND pronounce 'liseuse.'fengli can spell AND pronounce 'liseuse.'
 
Posts: 111
Karma: 39846
Join Date: Aug 2022
Device: PC
Quote:
Originally Posted by unkn0wn View Post
Code:
    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
try adding this to the recipe
I have tested many times and found that it still fails,The content is all empty and the links are gone please take another look, thank you very much
Test recipe:
#!/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'),
]

Google news-ceshi.recipe
Attached Thumbnails
Click image for larger version

Name:	屏幕截图 2023-02-04 180352.png
Views:	511
Size:	16.9 KB
ID:	199455  

Last edited by fengli; 02-04-2023 at 06:07 AM.
fengli is offline   Reply With Quote