Un pequeño script en Python que hice para buscar una definicion a cualquier palabra que se ingrese.

El codigo
#!usr/bin/python
#Diccionario Online 0.1
#Coded By Doddy H

import urllib2,re,sys,HTMLParser

def toma(web) :
 nave = urllib2.Request(web)
 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');
 op = urllib2.build_opener()
 return op.open(nave).read()

def head():
 print """


 @@@@    @             @                      @      
 @   @                                               
 @    @                                              
 @    @  @  @@@   @@@  @  @@@  @ @@   @@@  @@ @  @@@ 
 @    @  @ @   @ @   @ @ @   @ @@  @     @ @  @ @   @
 @    @  @ @     @     @ @   @ @   @  @@@@ @  @ @   @
 @    @  @ @     @     @ @   @ @   @ @   @ @  @ @   @
 @   @   @ @   @ @   @ @ @   @ @   @ @   @ @  @ @   @
 @@@@    @  @@@   @@@  @  @@@  @   @  @@@@ @  @  @@@ 


                                          
                              Coded By Doddy H

                                       
"""

def copyright():
 print "\n\n(C) Doddy Hackman 2012\n"
 raw_input()
 sys.exit(1)

head()

url = raw_input("\n\n[+] Palabra : ")

try:
 code = toma("http://es.thefreedictionary.com/"+url)
 if (re.findall("<div class=runseg><b>1 <\/b>&nbsp; (.*?)[.:<]",code)):
   re = re.findall("<div class=runseg><b>1 <\/b>&nbsp; (.*?)[.:<]",code)
   re = re[0]
   htmlparser = HTMLParser.HTMLParser()
   re = htmlparser.unescape(re)

   if not re=="":
     print "\n\n[+] Definicion : "+re
   else:
     print "[-] No se encontro significado\n"
except:
 print "[-] Error\n"
 
copyright()

# The End
Responder

Volver a “Fuentes”