mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update NZZ Online
This commit is contained in:
parent
7552e35b6b
commit
a887ee24be
@ -42,7 +42,6 @@ class Nzz(BasicNewsRecipe):
|
|||||||
soup = self.index_to_soup(baseref)
|
soup = self.index_to_soup(baseref)
|
||||||
|
|
||||||
articles = {}
|
articles = {}
|
||||||
key = None
|
|
||||||
ans = []
|
ans = []
|
||||||
|
|
||||||
issuelist = soup.find(id="issueSelectorList")
|
issuelist = soup.find(id="issueSelectorList")
|
||||||
@ -52,27 +51,25 @@ class Nzz(BasicNewsRecipe):
|
|||||||
section = f.string
|
section = f.string
|
||||||
sectionref = baseref + f['href']
|
sectionref = baseref + f['href']
|
||||||
|
|
||||||
# print "section is "+section +" and ref is "+sectionref
|
|
||||||
ans.append(section)
|
ans.append(section)
|
||||||
|
|
||||||
articlesoup = self.index_to_soup(sectionref)
|
articlesoup = self.index_to_soup(sectionref)
|
||||||
|
|
||||||
articlesoup = articlesoup.findAll('article','article')
|
articlesoup = articlesoup.findAll('article','article')
|
||||||
for a in articlesoup:
|
for a in articlesoup:
|
||||||
artlink = a.find('a')
|
artlink = a.find('a')
|
||||||
|
|
||||||
arthref = baseref + artlink['href']
|
arthref = baseref + artlink['href']
|
||||||
arthead = a.find('h2')
|
arthead = a.find('h2')
|
||||||
artcaption = arthead.string
|
artcaption = arthead.string
|
||||||
|
|
||||||
pubdate = strftime('%a, %d %b')
|
pubdate = strftime('%a, %d %b')
|
||||||
|
|
||||||
if not artcaption is None:
|
if not artcaption is None:
|
||||||
# print " found article named "+artcaption+" at "+arthref
|
if not articles.has_key(section):
|
||||||
if not articles.has_key(section):
|
articles[section] = []
|
||||||
articles[section] = []
|
articles[section].append(
|
||||||
articles[section].append(
|
dict(title=artcaption, url=arthref, date=pubdate, description='', content=''))
|
||||||
dict(title=artcaption, url=arthref, date=pubdate, description='', content=''))
|
|
||||||
|
|
||||||
ans = [(key, articles[key]) for key in ans if articles.has_key(key)]
|
ans = [(key, articles[key]) for key in ans if articles.has_key(key)]
|
||||||
return ans
|
return ans
|
||||||
@ -80,10 +77,10 @@ class Nzz(BasicNewsRecipe):
|
|||||||
def get_browser(self):
|
def get_browser(self):
|
||||||
br = BasicNewsRecipe.get_browser(self)
|
br = BasicNewsRecipe.get_browser(self)
|
||||||
if self.username is not None and self.password is not None:
|
if self.username is not None and self.password is not None:
|
||||||
br.open('https://webpaper.nzz.ch/login')
|
br.open('https://cas.nzz.ch/cas/login')
|
||||||
br.select_form(nr=0)
|
br.select_form(nr=0)
|
||||||
br['_username'] = self.username
|
br['username'] = self.username
|
||||||
br['_password'] = self.password
|
br['password'] = self.password
|
||||||
br.submit()
|
br.submit()
|
||||||
return br
|
return br
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user