EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff
Hacker's Home Page
IRC Flash Chat

Training Missions

Read Me First
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra

Knowledge Bank

Discussion Forums
Exploit Database New
PasteBin New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Downloads
Tools

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Pimp Us Out!

Review enigmagroup.org on alexa.com

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.

Enigma Group

Enigma Group

Enigma Group

Enigma Group
 

Enigma Group's Code Bank


Python Dictionary

By: Futility  -  Date Submitted: 2009-05-11 17:59:57

  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. #Takes a list of words from a specified file, runs them
  3. # through dictionary.com and prints the definitions in a
  4. # new text document. Very useful for when your teacher
  5. # wants to give you homework, but there's nothing left
  6. # to assign, so she makes you copy 127 definitions from
  7. # the back of the book due the next day making you realize
  8. # what a waste of time the class is so you just make this
  9. # program instead... Anyway, here it is.
  10. #
  11. #Note: Only takes the first definition from each search. You can easily
  12. # change this by making it look for 2.</td><td> rather than 1.
  13. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  14.  
  15. import urllib2 #imports urllib2... can't get much simpler than that
  16.  
  17. print '--------------------------------------------------------------------------'
  18. print 'Hello and welcome to my dictionary program. In order to use it, you must'
  19. print 'create a text file in the same directory as the program. In the text file,'
  20. print 'you have to make a list of words you need to be defined, but'
  21. print 'make sure they\'re each on a new line or it won\'t work. The script then runs'
  22. print 'through the list and places each word into a search on dictionary.com.'
  23. print 'It then copies the definitions and saves them into the specified file.'
  24. print ' Enjoy'
  25. print
  26. print 'Created By: Futility'
  27. print 'Written In: Python'
  28. print '--------------------------------------------------------------------------'
  29. print
  30. saveTo = raw_input("What would you like the output file to be named? (Be sure to include the .txt)\n")
  31. DefFile = open(saveTo,"w") #Opens the file where the definitions will be saved
  32.  
  33. wordlist = raw_input("What text file will the words be located in? (Once again, .txt is important)\n")
  34. f = open(wordlist) #Opens the file where the words are
  35.  
  36. for line in f: #starts the loop that'll read through your list of words
  37. page = urllib2.urlopen('http://dictionary.reference.com/browse/' + line) #opens the dictionary.com page for your words
  38. html = page.read() #saves the source of the opened page
  39.  
  40. #Get the definition
  41. pos = html.find('1.</td> <td>')#Find where you need to start from the source
  42. definition = html[pos+12:]#Cut out all the unnecessary tags
  43. endpos = definition.find('<')#Define the end position as the start of a new tag
  44. definition = definition[:endpos]#Combine the start and stop to get the full definition
  45.  
  46. DefFile.write(line + definition + '\n\n')#Write the definition to the file with two newlines for formatting purposes
  47.  
  48. print 'Congratulations, you\'re done. Check ' + saveTo + ' for all your new definitions.'
  49. print ' You\'re Welcome.'
  50.  
  51. #Close the files. Not really necessary, but I do it anyway.
  52. f.close()
  53. DefFile.close()
  54.  
Return to python category list

Who Visited EnigmaGroup Today?

1647 Guests, 147 Users (157 Spiders)
milindsalvlve, todearshan, Evil1, ravikiranh, diabolo94, Anonanonamous, f0gh0rn, gohmushroom, itsukiminami2, Anonymousfigure, ellisp, untchable, Nemoxias, dnoz78, tehuringa, tulu, akhil, Abhinav2107, st3alth, ktsukino, riker987, ropopopo, maddy, ExpDel, D3ath, haidedesu, yentup, neuron, so0bi34, rinkiyoshikinjo, Moff, kaucha, Nightraven, Peid0, mOI, Arsenal, cosmo, GothicLogic, leonheart, Heugal, NoPc, Ausome1, bbml, Red, gigajum, cls777, dark_void, Megji, Devio, Marko Bijelic, zombiehack640, wx3gamer, jimmy1693, Alberto, Zylinx™, timthemale, Farrella1, proman, edeck, 9r4n+on, suplolx, cor3dump, Padraig.Nolan, seichi, asm0daios, c0d3br4wl3r, lam_zodiac, Wade, KidNinja, Futility, fatal, echo_steps, vinmen, xsiemich, potato18, Maleus, dpd29, y2k_2000, babinem, MBoomer, N4g4c3N, Bahamut, falber, Raell, nocow4bob, statix, Mr Pacifist, pqouewhsldghlsg, kaitou_kid, xthomd, lucca65, giovanni, sanjaydeshmukh380, Ghosterr, Ton That Vinh, JaRam, Medeoker, Jesser, delta30, psychomarine, dark_executer, nSoul, raybendegun, vipro, jbrown, harsh419heavy, CrashOverron, dagey, vishnu koppala, AcidAvenger, pquake, voodooKobra, Annumbo, Null Set, Doraga, panda_hacker, qty92, eusouumpeixe, obm0rok, Unlift, basti, Simad, Owlclaw, mahesh, Garfik666, hackaday, matewan, c0re, Arkz.Ruby, Craylien, ApexGfx, Mr.McCoy, intersys, musamanyama, unknown1346, edwin092, mgkorman, Rex_Mundi, VonGuntherz, lol, Dude2, Adelaido, hacksaw24, Synick, £ûpletcherer¡­¡­¡­|h¡­¡­., Arc, prabhu
 
Enigma Group