#!/bin/bash # crossword, # a wget-based nytimes crossword downloader # Liz A. Denys (liz@lizdenys.com) # Last updated on May 13, 2015 # This script downloads today's New York Times daily crossword. To # use, you must change the email and password information below so # that it corresponds to your premium New York Times account. # Get the current date. puzdate=`date "+%Y-%m-%d"` pdfdate=`date "+%b%d%y"` # Get the login page. wget --no-check-certificate https://myaccount.nytimes.com/auth/login \ -O login.html &>/dev/null # Scrape token and expires values so wget can auth. token=`grep token login.html | sed -e 's/^.*value="\([0-9a-f]\+\)".*$/\1/'` expires=`grep expires login.html | sed -e 's/^.*value="\([0-9a-f]\+\)".*$/\1/'` # Log in with password. Note: this does not work without replacing # username and password information. wget --post-data \ "userid=USERNAME%40DOMAIN.COM&password=PASSWORDVALUE&is_continue=false&remember=true&token=$token&expires=$expires" \ --save-cookies=cookies.txt --keep-session-cookies --no-check-certificate \ -O /dev/null https://myaccount.nytimes.com/auth/login &>/dev/null # Download puzzle in .pdf and .puz formats. wget --load-cookies=cookies.txt \ http://www.nytimes.com/svc/crosswords/v2/puzzle/print/$pdfdate.pdf \ &>/dev/null wget --load-cookies=cookies.txt \ http://www.nytimes.com/svc/crosswords/v2/puzzle/daily-$puzdate.puz \ &>/dev/null # Clean up workspace. rm cookies.txt rm login.html