Last active
March 29, 2023 18:04
-
-
Save colematt/3ccba2918f245b81efbec17132deed3e to your computer and use it in GitHub Desktop.
Download a wordlist file from a remote server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| import urllib.request | |
| from urllib.error import URLError | |
| from string import whitespace | |
| # Fetch a wordlist | |
| try: | |
| data = urllib.request.urlopen("https://raw.githubusercontent.com/colematt/english-words/master/words_alpha.txt") | |
| wordlist = list(word.decode("utf-8").lower().rstrip(whitespace) for word in data.readlines()) | |
| except URLError as e: | |
| print("Couldn't reach the dictionary server. Reason: %s" % e.reason) | |
| raise(e) | |
| except HTTPError as e: | |
| print("The dictionary server couldn't fulfill the request. Error code: %s" % e.code) | |
| raise(e) | |
| except Exception as e: | |
| print("Something else went wrong.") | |
| raise(e) | |
| finally: | |
| print("Loaded the dictionary. Found %i words." % len(wordlist)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment