View Single Post
Old 05-24-2010, 04:59 PM   #1979
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by dwanthny View Post
Is there the option of using wildcards when subbing out for the print version?
I think the usual way to handle this type of situation is to use the split function and split on the slash character. That will give you a list, with each element in the list being text in the original URL that was separated by a slash. Then insert the "v-print" text into the list, then reassemble using slashes.
Like this:
Code:
    def print_version(self, url):
        parts = url.split('/')
        print_url = 'http://' + parts[2] + '/' + parts[3] + '/' + parts[4] + '/' + parts[5] + '/'  + parts[6] \
                + '/v-print/' + parts[7] + '/' + parts[8]
        return print_url

Last edited by Starson17; 05-24-2010 at 05:02 PM.
Starson17 is offline