|
|
#1 |
|
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Oct 2009
Location: Doha, Qatar
Device: Sony PRS-505 iTouch iPhone
|
Print Version
Greetings,
Please have some patience as I'm not a python/web/html/soup developer ![]() I am trying to return the print version of an article from an rss feed. The url looks something like this: http://www.news24.com/Content/SouthA...intenance_bill The print version url looks like this: http://www.news24.com/printArticle.a...aff46&cid=1059 The problem is that the print url is supplied through a java script: <script language="JavaScript"> function openPrintWindow() { myPrintWindow = window.open('http://www.news24.com/printArticle.aspx?iframe&aid=1cfd873e-535e-4b5a-b944-da15f15aff46&cid=1059','myPrintWindow','toolbar=0, location=0,directories=0,status=0,menubar=0,scroll bars=1,resizable=0,width=750,height=600'); } </script> So, what is the easiest way to grab that URL from the java script? I've looked at some of the builtin recipes but could not find anything that relates to a specific case like this. Or maybe I just didn't understand the python code ![]() Any help appreciated. Regards, Neels |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,616
Karma: 28549044
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
use a regular expression to match the text in the javascript.
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Oct 2009
Location: Doha, Qatar
Device: Sony PRS-505 iTouch iPhone
|
Ok,
A little example: Q: How do I travel from Z to Y? A: Use an automobile. Not to belittle the regular expression answer, but .... uhhmmmm HOW? Does anyone have some sample code using regular expressions? Regards, Neels |
|
|
|
|
|
#4 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,616
Karma: 28549044
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
is the javascript in the feed file or in the html linked to by the rss feed?
|
|
|
|
|
|
#5 |
|
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 800
Karma: 194644
Join Date: Dec 2007
Location: Argentina
Device: Kindle Voyage
|
This is what you should use:
Code:
def print_version(self, url):
artl = url.rpartition('/')[0]
artl2 = artl.rpartition('/')[0]
rrest, sep, aid= artl3.rpartition('/')
cid = rrest.rpartition('/')[2]
return 'http://www.news24.com/printArticle.aspx?iframe&aid=' + aid + '&cid=' + cid
|
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Oct 2009
Location: Doha, Qatar
Device: Sony PRS-505 iTouch iPhone
|
Thanks!! Will try that tonight. Much appreciated.
<edit> PERFECT. I will study it a bit as there is another site using a similar method and post both recipes when done. Thanks again. Last edited by Neels; 10-12-2009 at 04:18 PM. |
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| If i have a print version... | dhume01 | General Discussions | 3 | 10-06-2010 09:38 PM |
| Print vs Pixel: retailers experiment with print/ebook bundles | DMcCunney | General Discussions | 42 | 09-15-2010 12:29 PM |
| Downloading and Converting Print version of RSS article | Daanish87 | Calibre | 1 | 06-11-2010 03:08 AM |
| Proper code for fetching Print Version from WSJ and NYT? | brad382 | Calibre | 1 | 12-20-2008 02:06 PM |
| NY Times owner - Print version irrelevant or gone in 5 years | Bob Russell | News | 12 | 02-10-2007 05:26 PM |