Okay, so today I wanted to get the New York Times crossword puzzle downloaded automatically. I’ve been doing it manually for, like, ever, and it’s a pain. Figured it was time to automate this thing.
Finding the Source
First things first, I needed to figure out where the puzzle actually comes from. I poked around the NYT site, but it’s all wrapped up in JavaScript and stuff. No easy download link, of course.
So, I started digging with the developer tools in my browser. You know, the “Inspect Element” thing. I opened that up, went to the Network tab, and then loaded the crossword page. Saw a bunch of stuff fly by, but one thing caught my eye – a file ending in “.puz”. Bingo!
It was some kind of weird-looking URL, all numbers and letters. But I figured, hey, it’s a file, right? Let’s try downloading it directly.
Getting the File
I copied that .puz URL and pasted it into a new browser tab. Hit enter, and boom! My browser downloaded the puzzle file. Sweet! I now know where the puzzle lives. One hurdle cleared!
Automating the Download
Now, I don’t want to do this manual copy-paste every day. I’m a blogger that uses a lot of scripting. So, I fired up a text editor.
I remembered I wanted to make it simple, and now I just want to get it working at any cost, So I used curl
. It’s that command-line thing for grabbing stuff from the internet. Super handy.
I cooked up a simple command that grab the file:
curl [that weird .puz URL] > nyt_*
Ran that, and bam! The .puz file showed up right in my folder. Awesome!
Changed puzzle file name into a more user friendly name. And It worked just dandy, and I now have the new puzzle file with it’s new name!
So, yeah, that’s how I tackled the NYT crossword download. Not rocket science, but it saves me a few clicks every day. And hey, that’s what automation is all about, right?