[Tutor] Thank you for all your help.
epoch7
epoch7@charter.net
Fri, 31 Aug 2001 12:51:33 -0400
I thought it would be nice of me to post my program that all of you helped
me write. Maybe you won't have to write one
now! I'm a big believer in doing something right once, so other don't have
to :)
I added comments in it for all the other newbies out there like me :)
----------------------------
######################
# URL Smasher
#
# by
#
# Will Olbrys
#
# completed 8/29/2001
#
#This program eats up
#urls out of html source(or anywhere
#for that matter and spits them
#back out with a specific port
#attached if you want.
######################
import re
import string
import os
file1 = raw_input("Name of file to convert: ")
file2 = raw_input("Name of file to output to: ")
in_file = open(file1, "r")
out_file = open(file2, "w")
temp_file = open("temp", "w")
file_text = in_file.read()
regex = re.compile('url=(.*)&') #This line tells how to find the url. in
this case, in between 'url=' and &'
matches = regex.findall(file_text)
temp_file.write(string.join(matches,"\n"))
in_file.close()
temp_file.close()
temp_file = open("temp", "r")
file_text = temp_file.read()
out_file.write(string.replace(file_text,'com','com:8045'))
#the previous lineadds a port to it, if you dont want to add a port then
change com:8045 to com
#or whatever depending on how the name address ends.
temp_file.close()
out_file.close()
os.remove("temp")