mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix ESPN download
This commit is contained in:
parent
1f5a1fac4f
commit
9132c638a6
@ -10,18 +10,17 @@ import re
|
|||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
class ESPN(BasicNewsRecipe):
|
class ESPN(BasicNewsRecipe):
|
||||||
|
|
||||||
title = 'ESPN'
|
title = 'ESPN'
|
||||||
description = 'Sports news'
|
description = 'Sports news'
|
||||||
__author__ = 'Kovid Goyal'
|
__author__ = 'Kovid Goyal'
|
||||||
language = _('English')
|
language = _('English')
|
||||||
|
|
||||||
needs_subscription = True
|
needs_subscription = True
|
||||||
remove_tags = [dict(name='font', attrs={'class':'footer'}), dict(name='hr', noshade='noshade')]
|
remove_tags = [dict(name='font', attrs={'class':'footer'}), dict(name='hr', noshade='noshade')]
|
||||||
remove_tags_before = dict(name='font', attrs={'class':'date'})
|
remove_tags_before = dict(name='font', attrs={'class':'date'})
|
||||||
center_navbar = False
|
center_navbar = False
|
||||||
html2lrf_options = ['--base-font-size', '0']
|
|
||||||
|
|
||||||
feeds = [('Top Headlines', 'http://sports.espn.go.com/espn/rss/news'),
|
feeds = [('Top Headlines', 'http://sports.espn.go.com/espn/rss/news'),
|
||||||
'http://sports.espn.go.com/espn/rss/nfl/news',
|
'http://sports.espn.go.com/espn/rss/nfl/news',
|
||||||
'http://sports.espn.go.com/espn/rss/nba/news',
|
'http://sports.espn.go.com/espn/rss/nba/news',
|
||||||
@ -39,37 +38,37 @@ class ESPN(BasicNewsRecipe):
|
|||||||
'http://sports.espn.go.com/espn/rss/bassmaster/news',
|
'http://sports.espn.go.com/espn/rss/bassmaster/news',
|
||||||
'http://sports.espn.go.com/espn/rss/oly/news',
|
'http://sports.espn.go.com/espn/rss/oly/news',
|
||||||
'http://sports.espn.go.com/espn/rss/horse/news']
|
'http://sports.espn.go.com/espn/rss/horse/news']
|
||||||
|
|
||||||
def get_browser(self):
|
def get_browser(self):
|
||||||
br = BasicNewsRecipe.get_browser()
|
br = BasicNewsRecipe.get_browser()
|
||||||
br.set_handle_refresh(False)
|
br.set_handle_refresh(False)
|
||||||
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('http://espn.com')
|
br.open('http://espn.com')
|
||||||
br.select_form(nr=0)
|
br.select_form(nr=1)
|
||||||
br.form.find_control(name='username', type='text').value = self.username
|
br.form.find_control(name='username', type='text').value = self.username
|
||||||
br.form['password'] = self.password
|
br.form['password'] = self.password
|
||||||
br.submit()
|
br.submit()
|
||||||
br.set_handle_refresh(True)
|
br.set_handle_refresh(True)
|
||||||
return br
|
return br
|
||||||
|
|
||||||
def print_version(self, url):
|
def print_version(self, url):
|
||||||
if 'eticket' in url:
|
if 'eticket' in url:
|
||||||
return url.partition('&')[0].replace('story?', 'print?')
|
return url.partition('&')[0].replace('story?', 'print?')
|
||||||
match = re.search(r'story\?(id=\d+)', url)
|
match = re.search(r'story\?(id=\d+)', url)
|
||||||
if match:
|
if match:
|
||||||
return 'http://sports.espn.go.com/espn/print?'+match.group(1)+'&type=story'
|
return 'http://sports.espn.go.com/espn/print?'+match.group(1)+'&type=story'
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for div in soup.findAll('div'):
|
for div in soup.findAll('div'):
|
||||||
if div.has_key('style') and 'px' in div['style']:
|
if div.has_key('style') and 'px' in div['style']:
|
||||||
div['style'] = ''
|
div['style'] = ''
|
||||||
|
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
def postprocess_html(self, soup, first_fetch):
|
def postprocess_html(self, soup, first_fetch):
|
||||||
for div in soup.findAll('div', style=True):
|
for div in soup.findAll('div', style=True):
|
||||||
div['style'] = div['style'].replace('center', 'left')
|
div['style'] = div['style'].replace('center', 'left')
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user