Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: BigBear en 19 Marzo 2012, 02:05 am



Título: [Python] Diccionario Online 0.1
Publicado por: BigBear en 19 Marzo 2012, 02:05 am
Un pequeño script en Python que hice para buscar una definicion a cualquier palabra que se
ingrese.

El codigo

Código
  1. #!usr/bin/python
  2. #Diccionario Online 0.1
  3. #Coded By Doddy H
  4.  
  5. import urllib2,re,sys,HTMLParser
  6.  
  7. def toma(web) :
  8. nave = urllib2.Request(web)
  9. nave.add_header('User-Agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5');
  10. op = urllib2.build_opener()
  11. return op.open(nave).read()
  12.  
  13. def head():
  14. print """
  15.  
  16.  
  17. @@@@    @             @                      @      
  18. @   @                                              
  19. @    @                                              
  20. @    @  @  @@@   @@@  @  @@@  @ @@   @@@  @@ @  @@@
  21. @    @  @ @   @ @   @ @ @   @ @@  @     @ @  @ @   @
  22. @    @  @ @     @     @ @   @ @   @  @@@@ @  @ @   @
  23. @    @  @ @     @     @ @   @ @   @ @   @ @  @ @   @
  24. @   @   @ @   @ @   @ @ @   @ @   @ @   @ @  @ @   @
  25. @@@@    @  @@@   @@@  @  @@@  @   @  @@@@ @  @  @@@
  26.  
  27.  
  28.  
  29.                              Coded By Doddy H
  30.  
  31.  
  32. """
  33.  
  34. def copyright():
  35. print "\n\n(C) Doddy Hackman 2012\n"
  36. raw_input()
  37. sys.exit(1)
  38.  
  39. head()
  40.  
  41. url = raw_input("\n\n[+] Palabra : ")
  42.  
  43. try:
  44. code = toma("http://es.thefreedictionary.com/"+url)
  45. if (re.findall("<div class=runseg><b>1 <\/b>&nbsp; (.*?)[.:<]",code)):
  46.   re = re.findall("<div class=runseg><b>1 <\/b>&nbsp; (.*?)[.:<]",code)
  47.   re = re[0]
  48.   htmlparser = HTMLParser.HTMLParser()
  49.   re = htmlparser.unescape(re)
  50.  
  51.   if not re=="":
  52.     print "\n\n[+] Definicion : "+re
  53.   else:
  54.     print "[-] No se encontro significado\n"
  55. except:
  56. print "[-] Error\n"
  57.  
  58. copyright()
  59.  
  60. # The End
  61.