Daily delivery of an electronic newspaper

I subscribe to Investor’s Business Daily for insight and valuable education as I gradually learn how to effectively invest in the market. It comes out Monday-Friday and obviously is very time relevant. I initially signed up for the print version so that I could read it on the bus and have something to highlight. However, I ended up never getting it on time because it’d come in while I was at work and I’d end up not even looking at it when I got home. I switched to the electronic version, but then I’d end up not downloading and reading the thing for weeks at a time. I needed an ‘in-your-face’ solution, so I wrote up this little PHP script to automatically download the eIBD every day and a separate shell script to open the PDF at 9am on my computer every weekday morning. So, I essentially have it ‘delivered’ to my desktop when I log on my Mac in the morning!

Here’s an example script to show how I did it. I’ve removed the information specific to IBD. Keep in mind that this script, as presented, does not log in to anything and assumed a filename format like 020508.pdf. I wrote these scripts for Mac OS X 10.4 and used Cronnix to create the crontab entry. It could easily be done on a Windows machine as well using the utilities provided by that system.

<?php
//
// Provided as-is without warranty.
//


$ch = curl_init();
$today = date(mdy)

;if(date(w) == 0) {
  $monday = mktime(0, 0, 0, date(m), date(d)+1, date(y));
  $today = date(mdy, $monday);
}

if(date(w) ==  6) {
  $monday = mktime(0, 0, 0, date(m), date(d)+2, date(y));
  $today = date(mdy, $monday);
}

$pdf_url = http://www.example.com/pdf/ . $today.pdf;
$fp = fopen(/Users/username/path/to/pdf/archive/$today.pdf, w);

curl_setopt ($ch, CURLOPT_URL, $pdf_url);
curl_setopt ($ch, CURLOPT_FILE, $fp);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_exec ($ch);
curl_close ($ch);
fclose($fp);
?>

And the shell script to open the PDF…

DATE=`date ‘+%m%d%y’`;
FILE=~/path/to/pdf/archive/${DATE}.pdf;
if [ -e $FILE ]; then
  open /Applications/Preview.app $FILE;
fi

And the crontab used to download the PDF each day at 11pm and open the file for me at 9am.

30      23      *       *       *               php /path/to/script.php
0       9       *       *       1,2,3,4,5,7     sh /path/to/pdf_opener.sh

I might clean this up a bit, but I just wanted to share it in case anyone else had a similar need for daily download and view. Feel free to offer suggestions for other ways to achieve this.

Statesman.com & Austin360.com now on Twitter

Wondering why the local Austin paper doesn’t have a Twitter account so I can get updates like NYT. Ryan, thoughts?
Paul Menard via Twitter

Well, it’s true that you can find Twitter accounts for the New York Times, CNN, BBC, TechCrunch, et al. However, it’s not clear how many of those are actually official branding efforts by those media organizations. In fact, the open nature of the Twitter API and the fact that these companies offer their latest headlines as RSS feeds mean anyone can create a news “river”.

Regardless I had to take up the challenge after being called out directly. I quickly registered accounts from both Statesman.com and Austin360.com. A quick and dirty PHP script later set up as a cron job and voila! While these sites are among those of my employer, my Twitter accounts do not constitute an “official” use of this syndication method. The NYTimes twitter was set up in a similar vein by Jacob Harris

http://twitter.com/statesman
http://twitter.com/austin360

Update: I’ve turned off the cron job until some sort of contextual relevance can be offered to any potential users. Breaking news, weather, jury verdicts, traffic, ticket sales, event listings, A-List events are all options.

What are your thoughts? What kind of updates would you be interested in receiving?