|
|
#1 |
|
Junior Member
![]() 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) Any ideas... Thanks |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,617
Karma: 28549044
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Code:
url = ':'.join(url.split(':')[:-1])
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Oct 2008
Device: PRS 505
|
Thanks... I'm trying to replace : with / where would I insert that?
|
|
|
|
|
|
#4 |
|
Reticulator of Tharn
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 618
Karma: 400000
Join Date: Jan 2007
Location: EST
Device: Sony PRS-505
|
|
|
|
|
|
|
#5 |
|
Junior Member
![]() 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:')
|
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Oct 2008
Device: PRS 505
|
|
|
|
|
![]() |
|
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 09:47 AM |
| unable to process folder with spanish chars | jomaweb | Calibre | 6 | 02-04-2010 06:11 AM |
| unicode chars in epubs after flashing | hakim | Sony Reader | 4 | 10-12-2009 09:33 AM |
| URL for GutenText please | AlexBell | Workshop | 2 | 06-26-2009 02:18 AM |
| Bug (?) related to polish (non-ascii) chars | parasit | Calibre | 8 | 05-30-2009 04:55 PM |