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-13-2008, 03:26 AM   #1
DAiki
Junior Member
DAiki began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Oct 2008
Device: PRS 505
Replacing Chars in URL

Hi All,

Not familiar with python at all I need to write regexp or some other way to replace : within the url.

What I have are links like this /story/55571:83405 problem is that parser is taking last five digits as port number while it's actually query string parameter that site is using.

I can not use just use straight replace as that would foul up the http:// bit.

Trying to use this

Code:
def print_version(self, url):
   return re.sub(r'(\d):(\d)','\1/\2',url)
But not luck yet...

Any ideas...

Thanks
DAiki is offline   Reply With Quote
Old 10-13-2008, 04:18 AM   #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,850
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Code:
url = ':'.join(url.split(':')[:-1])
kovidgoyal is offline   Reply With Quote
Old 10-13-2008, 04:41 AM   #3
DAiki
Junior Member
DAiki began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Oct 2008
Device: PRS 505
Thanks... I'm trying to replace : with / where would I insert that?
DAiki is offline   Reply With Quote
Old 10-13-2008, 09:00 AM   #4
llasram
Reticulator of Tharn
llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.
 
llasram's Avatar
 
Posts: 618
Karma: 400000
Join Date: Jan 2007
Location: EST
Device: Sony PRS-505
Quote:
Originally Posted by DAiki View Post
Thanks... I'm trying to replace : with / where would I insert that?
Code:
url = url.replace(':', '/')
llasram is offline   Reply With Quote
Old 10-13-2008, 09:24 AM   #5
DAiki
Junior Member
DAiki began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Oct 2008
Device: PRS 505
Just in case anybody needs this sort of think in the future I end up doing just replace 2x

Code:
        url = url.replace(':','/')
        url = url.replace('http/','http:')
DAiki is offline   Reply With Quote
Old 10-13-2008, 09:25 AM   #6
DAiki
Junior Member
DAiki began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Oct 2008
Device: PRS 505
Quote:
Originally Posted by llasram View Post
Code:
url = url.replace(':', '/')
TX that was my initial thinking until I realized that all : would be changed...
DAiki is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classic How to: Nook with any font (incl. Czech/Slovak/Russian/Polish and other chars) lamzor Nook Developer's Corner 4 08-26-2010 08:47 AM
unable to process folder with spanish chars jomaweb Calibre 6 02-04-2010 05:11 AM
unicode chars in epubs after flashing hakim Sony Reader 4 10-12-2009 08:33 AM
URL for GutenText please AlexBell Workshop 2 06-26-2009 01:18 AM
Bug (?) related to polish (non-ascii) chars parasit Calibre 8 05-30-2009 03:55 PM


All times are GMT -4. The time now is 11:27 AM.


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