Skip to content

Instantly share code, notes, and snippets.

@ceteri
Created May 6, 2022 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ceteri/9b652f55fc3595f436a7401b9a1fad23 to your computer and use it in GitHub Desktop.
Save ceteri/9b652f55fc3595f436a7401b9a1fad23 to your computer and use it in GitHub Desktop.
anagram words
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