Quote:
Originally Posted by mohmedic
rty,
thanks for your help but I still am at a loss. i added the print page lines and now get less. i don't think i set up the split right (copy and paste from tech review and altered)
Spoiler:
Code:
class AdvancedUserRecipe1279635146(BasicNewsRecipe):
title = u'EMS1'
oldest_article = 7
max_articles_per_feed = 100
use_embedded_content = False
feeds = [(u'columnist', u'http://www.ems1.com/ems-rss-feeds/columnists.xml'),
(u'topics', u'http://www.ems1.com/ems-rss-feeds/topics.xml'),
(u'most popular', u'http://www.ems1.com/ems-rss-feeds/most-popular-articles.xml'),
(u'EMS Tips', u'http://www.ems1.com/ems-rss-feeds/tips.xml'),
(u'Daily news', u'http://www.ems1.com/ems-rss-feeds/news.xml')]
def print_version(self, url):
baseurl='http://www.ems1.com/print.asp?act=print&vid='
split1 = string.split(url,"/")
xxx=split1 [4]
split2= string.split(xxx,"-")
s = baseurl + split2[0]
return s
|
You have a couple of problems. To start, you didn't import string.
You can fix that with:
import string
from calibre.web.feeds.news import BasicNewsRecipe
Next, your xxx=split1 [4] is wrong. Worse, it sometimes should be xxx=split1[5] and other times should be xxx=split1[6]
You need to test the result of the split2 to see if it's an integer. There's lots of ways to do it. I used a try/except and integer conversion. I also changed the split, so the import of string is not needed, but I left it in, in case you want to use it. Note that this only works if the number you need is in position 5 or 6. I didn't test all the recipe to see if it's ever in another location in the URL
Try this:
Spoiler:
Code:
import string
from calibre.web.feeds.news import BasicNewsRecipe
class AdvancedUserRecipe1279635146(BasicNewsRecipe):
title = u'EMS1'
oldest_article = 7
max_articles_per_feed = 100
use_embedded_content = False
feeds = [(u'columnist', u'http://www.ems1.com/ems-rss-feeds/columnists.xml'),
(u'topics', u'http://www.ems1.com/ems-rss-feeds/topics.xml'),
(u'most popular', u'http://www.ems1.com/ems-rss-feeds/most-popular-articles.xml'),
(u'EMS Tips', u'http://www.ems1.com/ems-rss-feeds/tips.xml'),
(u'Daily news', u'http://www.ems1.com/ems-rss-feeds/news.xml')]
def print_version(self, url):
baseurl='http://www.ems1.com/print.asp?act=print&vid='
split1 = url.split("/")
xxx=split1[6]
split2= xxx.split("-")
yyy = split1[5]
split3= yyy.split("-")
try:
final =str(int(split2[0]))
except:
final = str(int(split3[0]))
s = baseurl + final
return s