Update Publico.PT

Fixes #1961348 [Fix username/password on Publico recipe](https://bugs.launchpad.net/calibre/+bug/1961348)
This commit is contained in:
Kovid Goyal 2022-02-18 07:16:39 +05:30
parent 87b527d33e
commit 1c0796be45
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -9,6 +9,7 @@ publico.pt
'''
from calibre.web.feeds.news import BasicNewsRecipe
from polyglot.urllib import urlencode
def classes(classes):
@ -29,6 +30,7 @@ class PublicoPT(BasicNewsRecipe):
language = 'pt'
remove_empty_feeds = True
extra_css = ' body{font-family: Arial,Helvetica,sans-serif } img{margin-bottom: 0.4em} '
needs_subscription = True
keep_only_tags = [
dict(id='story-content story-header'.split()),
@ -53,6 +55,23 @@ class PublicoPT(BasicNewsRecipe):
(u'Tecnologia', u'http://feeds.feedburner.com/PublicoTecnologia')
]
def get_browser(self):
br = BasicNewsRecipe.get_browser(self)
if self.username is not None and self.password is not None:
postdata = urlencode({
'username': self.username,
'password': self.password
})
br.open(
'https://www.publico.pt/api/user/login',
data=postdata,
timeout=self.timeout
)
br.set_handle_refresh(True)
return br
def preprocess_html(self, soup):
for img in soup.findAll('img', attrs={'data-media-viewer':True}):
img['src'] = img['data-media-viewer']