-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathanagram_unscramble_scrape.nu
16 lines (16 loc) · 1.08 KB
/
anagram_unscramble_scrape.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env nu
# script to get anagrams with scrabble points from unscramble.me
# NOTE: this is just a small show case of piping query web stuff
def main [...words: string] {
let base = "https://www.unscramble.me/"
$words | par-each {
|word|
http get ($base + $word)
|query web -q ".mBottom-6" -m # gets the anagram table part of the page
|drop nth 0 # remove the description/definition of "words"
|first # we only care about the biggest/first anagrams (which is the length of the input word)
|query web -q "table" -m # get the html table
|to text # we need it as raw html to parse it
|query web --as-table ["Word" "Scrabble points" "Words with friends points"] # parse the html table as table
}
}