Quote:
Originally Posted by dwanthny
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