View Single Post
Old 12-09-2010, 11:24 AM   #4
TonytheBookworm
Addict
TonytheBookworm is on a distinguished road
 
TonytheBookworm's Avatar
 
Posts: 264
Karma: 62
Join Date: May 2010
Device: kindle 2, kindle 3, Kindle fire
What I would do is strip the url and re-append it
The original article within say the Health feed is something like this
http://www.ctv.ca/CTVNews/Health/201...umbers-101209/

and the print version is something like this:
http://www.ctv.ca/servlet/ArticleNew...hub=PrintStory

so what you would wanna do is strip the url after the http://www.ctv.ca/CTVNews/Health/ in the original url
that would leave you with two indexes.
1) http://www.ctv.ca/CTVNews/Health/
2) /20101209/nurses-numbers-101209/

then simply re split the second index so you get
1) 20101209
2) nurses-numbers-101209

then simply piece it back together
Spoiler:

Code:
def print_version(self, url):
        split1 = url.split("/CTVNews/Health/")
        split2 = url.split1("/")
        
        print_url = http://www.ctv.ca/servlet/ArticleNews/print/CTVNews/' + split1[1] + '/' + split2[0] + '/?hub=Health&subhub=PrintStory'
        
        return print_url


notice that this would only work for the health section. so you would have to take and use some for statements and if statements and a regexpression search to check and see if health is contained in the url. or whatever feeds you might have then break the url accordingly.

By the way the above code is not tested and will more than likely fail but you should get the general concept of how to go about it... Good luck.
TonytheBookworm is offline   Reply With Quote