Script or hack to show PDF from /YYYY/MM/DD/*.pdf URL?
May 15, 2014 12:58 PM   Subscribe

I just noticed that the NYT offers a PDF version of its print front page, which I'd like to be able to access without going through the extra clicks on the website. The file always has the same name as is located in a simple nested date format — but I have no idea how to script something to replace that every day in a new tab or add it to Rainmeter or the like. Any suggestions?

Here's the current URL:

http://www.nytimes.com/images/2014/05/15/nytfrontpage/scannat.pdf

If I could put together a bookmarklet or some kind of scripted grab that would load up today's version of that or put it in a local folder, that would be wonderful. (I can't make rainmeter show a PDF)

In case you can't tell, I'm pretty inexperienced in code, but thought this would be a good place to get some practical recommendations for where to start on a small thing like this.
posted by BlackLeotardFront to Computers & Internet (8 answers total) 2 users marked this as a favorite
 
If I just wanted an easy way to see the thing, I'd do it in TextExpander (I'd guess Windows has something that could do the same thing).

Something like: http://www.nytimes.com/images/%Y/%m/%d/nytfrontpage/scannat.pdf with a shortcut of .nytfront or something like that.

Put the cursor in the location bar, type the shortcut and you're done.
posted by brentajones at 1:21 PM on May 15, 2014


Response by poster: Good idea - I have phraseexpress which does that well - I'd like there to be something more automatic, though. Ideally it would just appear as a borderless front page on my desktop, like I'm passing by the paper dispenser on the street. I don't mind installing an app or engine or whatnot if it's necessary.
posted by BlackLeotardFront at 1:24 PM on May 15, 2014


Here's a quick Windows PowerShell script that downloads each day's pdf.
$today=get-date
$url = "http://www.nytimes.com/images/"+$today.year.ToString()+"/"+$today.month.ToString("00")+"/"+$today.day.ToString("00")+"/nytfrontpage/scannat.pdf"
$folderlocal = "C:\Dropbox\"
$filelocal=$today.year.ToString()+$today.month.ToString("00")+$today.day.ToString("00")+".pdf"
$localfull= $folderlocal+$filelocal
$client = New-Object System.Net.WebClient
$client.DownloadFile($url, $localfull)
You could automate running this script through the task scheduler following the instructions here
posted by fjom at 1:31 PM on May 15, 2014


You could create a local html file and either bookmark it or use it as your front page:

Here's something I whipped up on JS Bin - just paste the contents into a text editor (Notepad for example) and save as a .html file.
posted by backwards guitar at 1:38 PM on May 15, 2014


I missed the last line of the script (to open the file with your default PDF reader):
start-process $localfull

posted by fjom at 1:44 PM on May 15, 2014


Response by poster: Thanks, these are useful. I can't get the PS script to work, though - it wants something different for start-process $localfull, though it does download the file. Not trying to make this a whole big Q&A on scripting, but if there's an obvious fix...
posted by BlackLeotardFront at 2:00 PM on May 15, 2014


MeFi filters JavaScript links, so I can't make this a draggable link/bookmarklet like I'd hoped. You'll have to copy the code below and paste it into a new bookmark manually created in your bookmark manager.

When clicked, it will go to the day's front page.

javascript:var d = new Date(); window.location.href = 'http://www.nytimes.com/images/'+d.getFullYear()+'/'+(d.getMonth() < 9 ? '0'+(d.getMonth()+1) : d.getMonth()+1)+'/'+(d.getDate() < 10 ? '0'+d.getDate() : d.getDate())+'/nytfrontpage/scannat.pdf';
posted by WasabiFlux at 2:46 PM on May 15, 2014 [2 favorites]


I don't have a lot of experience with Power Shell versions, but Notepad++ does not highlight Start-Process as a PS Action and it did highlight Invoke-Item which in this case does the same. So maybe if you try changing the last line to:
invoke-item $localfull
(both work on my PC)
posted by fjom at 7:40 AM on May 16, 2014


« Older Technology and design patterns for x-platform app?   |   what basic word processing application for osx... Newer »
This thread is closed to new comments.