Created
May 6, 2022 20:14
-
-
Save ceteri/9b652f55fc3595f436a7401b9a1fad23 to your computer and use it in GitHub Desktop.
anagram words
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
import pathlib | |
import sys | |
from icecream import ic | |
import requests | |
term = "weather" | |
words = set([]) | |
api_url = "https://new.wordsmith.org/anagram/anagram.cgi?anagram={}&t=500&a=n".format(term) | |
response = requests.get(api_url) | |
pat_head = "Displaying all:" | |
pat_done = "<script>document.body" | |
ignore = True | |
for i, line in enumerate(response.text.split("\n")): | |
if pat_done in line: | |
ignore = True | |
if not ignore: | |
for word in line.strip().lstrip("</b><br>").rstrip("<br>").split(" "): | |
words.add(word.lower()) | |
if ignore and pat_head in line: | |
ignore = False | |
print(len(words), words) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment