Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 10-04-2009, 03:33 PM   #1
Neels
Junior Member
Neels began at the beginning.
 
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
Neels is offline   Reply With Quote
Old 10-04-2009, 03:54 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
use a regular expression to match the text in the javascript.
kovidgoyal is offline   Reply With Quote
Advert
Old 10-04-2009, 11:26 PM   #3
Neels
Junior Member
Neels began at the beginning.
 
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
Neels is offline   Reply With Quote
Old 10-05-2009, 01:39 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
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?
kovidgoyal is offline   Reply With Quote
Old 10-05-2009, 07:53 PM   #5
kiklop74
Guru
kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.
 
kiklop74's Avatar
 
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
kiklop74 is offline   Reply With Quote
Advert
Old 10-12-2009, 03:09 PM   #6
Neels
Junior Member
Neels began at the beginning.
 
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 03:18 PM.
Neels is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
If i have a print version... dhume01 General Discussions 3 10-06-2010 08:38 PM
Print vs Pixel: retailers experiment with print/ebook bundles DMcCunney General Discussions 42 09-15-2010 11:29 AM
Downloading and Converting Print version of RSS article Daanish87 Calibre 1 06-11-2010 02:08 AM
Proper code for fetching Print Version from WSJ and NYT? brad382 Calibre 1 12-20-2008 01:06 PM
NY Times owner - Print version irrelevant or gone in 5 years Bob Russell News 12 02-10-2007 04:26 PM


All times are GMT -4. The time now is 12:56 PM.


MobileRead.com is a privately owned, operated and funded community.