Wednesday, November 24, 2010

Coding bat - solutions - Code

Now that the solutions are downloaded, i dont know how to attach them as a file link here, so i need to extract all the QUESTION - ANSWER part and post it ....there goes the parsing again.....

this is the program that i used to parse the output and save the contents...
import sys
import re
import os

directory = 'd:\\scripts\\myhack\\'
filelist = os.listdir(directory)

f = open(r'd:\full.html','w')
for filename in filelist:
    print filename
    file = open(os.path.join(directory,filename),'r')
    content = file.read()
    sindex = content.find('
')
    endIndex = content.find('')
    newcon = content[sindex:endIndex+11].replace('textarea','pre').replace('button','button style=\"visibility:hidden\"')+'
'
    f.write('---------------------------------------------------------------')
    f.write(''+filename+'')
    f.write('\n')
    f.write('---------------------------------------------------------------')
    f.write('\n')
    f.write(newcon)
    f.write('\n')
f.close()

No comments:

Post a Comment