| 1 |
#!/usr/bin/env python |
| 2 |
__license__ = 'GPL v3' |
| 3 |
__author__ = 'Tony Stegall' |
| 4 |
__copyright__ = '2010, Tony Stegall or Tonythebookworm on mobileread.com' |
| 5 |
__version__ = '1' |
| 6 |
__date__ = '01, October 2010' |
| 7 |
__docformat__ = 'English' |
| 8 |
|
| 9 |
|
| 10 |
from calibre.web.feeds.recipes import BasicNewsRecipe |
| 11 |
|
| 12 |
|
| 13 |
class MedScrape(BasicNewsRecipe): |
| 14 |
title = 'MedScape' |
| 15 |
__author__ = 'Tony Stegall' |
| 16 |
description = 'Nursing News' |
| 17 |
language = 'en' |
| 18 |
timefmt = ' [%a, %d %b, %Y]' |
| 19 |
needs_subscription = True |
| 20 |
masthead_url = 'http://images.medscape.com/pi/global/header/sp/bg-sp-medscape.gif' |
| 21 |
no_stylesheets = True |
| 22 |
remove_javascript = True |
| 23 |
conversion_options = {'linearize_tables': True} |
| 24 |
extra_css = ''' |
| 25 |
h1{font-family:Arial,Helvetica,sans-serif; font-weight:bold;font-size:large;} |
| 26 |
|
| 27 |
|
| 28 |
p.authors{text-align:right; font-size:small;margin-top:0px;margin-bottom: 0px;} |
| 29 |
p.postingdate{text-align:right; font-size:small;margin-top:0px;margin-bottom: 0px;} |
| 30 |
h2{text-align:right; font-size:small;margin-top:0px;margin-bottom: 0px;} |
| 31 |
|
| 32 |
|
| 33 |
p{font-family:Helvetica,Arial,sans-serif;font-size:small;} |
| 34 |
''' |
| 35 |
|
| 36 |
remove_tags = [dict(name='div', attrs={'class': ['closewindow2']}), dict(name='div', attrs={'id': ['basicheaderlinks']})] |
| 37 |
|
| 38 |
def get_browser(self): |
| 39 |
br = BasicNewsRecipe.get_browser(self) |
| 40 |
if self.username is not None and self.password is not None: |
| 41 |
br.open('https://profreg.medscape.com/px/getlogin.do') |
| 42 |
br.select_form(name='LoginForm') |
| 43 |
br['userId'] = self.username |
| 44 |
br['password'] = self.password |
| 45 |
br.submit() |
| 46 |
return br |
| 47 |
|
| 48 |
feeds = [ |
| 49 |
('MedInfo', 'http://www.medscape.com/cx/rssfeeds/2685.xml'), |
| 50 |
] |
| 51 |
|
| 52 |
def print_version(self, url): |
| 53 |
# the original url is: http://www.medscape.com/viewarticle/728955?src=rss |
| 54 |
# the print url is: http://www.medscape.com/viewarticle/728955_print |
| 55 |
print_url = url.partition('?')[0] + '_print' |
| 56 |
# print('the printable version is: ',print_url) |
| 57 |
return print_url |
| 58 |
|
| 59 |
def preprocess_html(self, soup): |
| 60 |
for item in soup.findAll(attrs={'style': True}): |
| 61 |
del item['style'] |
| 62 |
return soup |