Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a small query web showcase with unscramble.me #452

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions webscraping/anagram_unscramble_scrape
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
}
}