mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Fix #2236 (Updated Tom's Hardware recipe)
This commit is contained in:
parent
77fc9f00fe
commit
ec8431579d
@ -1,38 +1,47 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
'''
|
'''
|
||||||
tomshardware.com
|
tomshardware.com/us
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import urllib
|
||||||
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
||||||
from calibre.web.feeds.recipes import BasicNewsRecipe
|
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||||
|
|
||||||
class Tomshardware(BasicNewsRecipe):
|
class Tomshardware(BasicNewsRecipe):
|
||||||
|
|
||||||
title = "Tom's Hardware US"
|
title = "Tom's Hardware US"
|
||||||
__author__ = 'Darko Miletic'
|
__author__ = 'Darko Miletic'
|
||||||
description = 'Hardware reviews and News'
|
description = 'Hardware reviews and News'
|
||||||
|
publisher = "Tom's Hardware"
|
||||||
|
category = 'news, IT, hardware, USA'
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
needs_subscription = True
|
needs_subscription = True
|
||||||
language = _('English')
|
language = _('English')
|
||||||
INDEX = 'http://www.tomshardware.com'
|
INDEX = 'http://www.tomshardware.com'
|
||||||
LOGIN = 'http://www.tomshardware.com/membres/?r=%2Fus%2F#loginForm'
|
LOGIN = INDEX + '/membres/'
|
||||||
cover_url = 'http://img.bestofmedia.com/img/tomshardware/design/tomshardware.jpg'
|
remove_javascript = True
|
||||||
|
use_embedded_content= False
|
||||||
|
|
||||||
html2lrf_options = [ '--comment' , description
|
html2lrf_options = [
|
||||||
, '--category' , 'hardware,news'
|
'--comment', description
|
||||||
, '--base-font-size', '10'
|
, '--category', category
|
||||||
|
, '--publisher', publisher
|
||||||
]
|
]
|
||||||
|
|
||||||
|
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
|
||||||
|
|
||||||
def get_browser(self):
|
def get_browser(self):
|
||||||
br = BasicNewsRecipe.get_browser()
|
br = BasicNewsRecipe.get_browser()
|
||||||
|
br.open(self.INDEX+'/us/')
|
||||||
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(self.LOGIN)
|
data = urllib.urlencode({ 'action':'login_action'
|
||||||
br.select_form(name='connexion')
|
,'r':self.INDEX+'/us/'
|
||||||
br['login'] = self.username
|
,'login':self.username
|
||||||
br['mdp' ] = self.password
|
,'mdp':self.password
|
||||||
br.submit()
|
})
|
||||||
|
br.open(self.LOGIN,data)
|
||||||
return br
|
return br
|
||||||
|
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
@ -49,9 +58,10 @@ class Tomshardware(BasicNewsRecipe):
|
|||||||
main, sep, rest = url.rpartition('.html')
|
main, sep, rest = url.rpartition('.html')
|
||||||
rmain, rsep, article_id = main.rpartition(',')
|
rmain, rsep, article_id = main.rpartition(',')
|
||||||
tmain, tsep, trest = rmain.rpartition('/reviews/')
|
tmain, tsep, trest = rmain.rpartition('/reviews/')
|
||||||
|
rind = 'http://www.tomshardware.com/news_print.php?p1='
|
||||||
if tsep:
|
if tsep:
|
||||||
return 'http://www.tomshardware.com/review_print.php?p1=' + article_id
|
rind = 'http://www.tomshardware.com/review_print.php?p1='
|
||||||
return 'http://www.tomshardware.com/news_print.php?p1=' + article_id
|
return rind + article_id
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
del(soup.body['onload'])
|
del(soup.body['onload'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user