#------------------------------------------------------------------------------
# Pequeño script de escritorio para utilizar Codepad.org
# Programmer: The Swash
# Website: http://h-sec.org
#------------------------------------------------------------------------------
import urllib, urllib2, re
def GetResponse(lang, code):
code = urllib.urlencode({'lang':lang, 'code':code,'run':'True','submit':'Submit'})
web = urllib2.urlopen('http://codepad.org',code)
source = web.read()
resp = re.findall('<td width="100%" style="vertical-align: top">\n<div class="highlight">\n<pre>\n([^\b]+)</pre>', source)
temp = resp[0]
if re.findall('<a href="#line-[\d]">(.+)</a>', temp):
err = re.findall('<a href="#line-[0-9]">(.+)</a>', temp)
val = re.sub('<a href="#line-[0-9]">(.+)</a>', err[0], temp)
return val
else:
return temp
langs = ('Python','C','C++','PHP','Perl','Ruby')
lang = 0
print "Bienvenido, lenguajes disponibles: \n"
length = len(langs)
for i in range(length):
print str(i+1) + '- ' + langs[i]
while not((ord(str(lang)) >= 49) and (ord(str(lang)) <= 54)):
print "Elige el numero correspondiente: "
lang = input()
try:
path = raw_input("Ingrese la ubicacion completa del archivo: ")
lfile = open(path, "r")
buff = lfile.read()
lfile.close()
except:
print "Error al procesar archivo"
exit()
Resp = GetResponse(langs[lang-1], buff)
print "Output:\n"
print Resp
raw_input("Presione enter para salir..")