Skip to content

Instantly share code, notes, and snippets.

@Christopher-A
Forked from rcw3/gist:2018059
Created March 14, 2012 01:25
Show Gist options
  • Save Christopher-A/2033205 to your computer and use it in GitHub Desktop.
Save Christopher-A/2033205 to your computer and use it in GitHub Desktop.
Self-contained WWDC Status Checker With Prowl For Cron Jobs
#!/bin/bash
api_key="your Prowl API key goes here"
cd ~
testSiteForChanges () {
ls "old_page.html" 1>/dev/null 2>/dev/null
if [ $? -eq "1" ] ; then
curl $1 --silent -o old_page.html
fi
curl $1 --silent -o new_page.html
diff old_page.html new_page.html 1>/dev/null
if [ $? -eq "0" ] ; then
page_changed=0
else
page_changed=1
fi
rm new_page.html
return $page_changed
}
#testSiteForChanges "http://www.cnn.com"
testSiteForChanges "https://developer.apple.com/wwdc/"
if [ $? -eq "1" ] ; then
url="https://api.prowlapp.com/publicapi/add?apikey=${api_key}"
url="${url}&application=WWDC%202012"
url="${url}&event=Registration%20Open"
url="${url}&description=It%20is%20time...%20maybe."
url="${url}&priority=2"
curl -k -s ${url}
fi
@bobspryn
Copy link

bobspryn commented Apr 8, 2012

Need to add a second check in there against the occasional 404 that pops up.

if [ $? -eq "0" ] ; then
    page_changed=0
else
    diff wwdc404.html new_page.html 1>/dev/null
    if [ $? -eq "0" ] ; then
        page_changed=0
    else
        page_changed=1
    fi
fi

the 404 code looks like this, note there is a newline at the end that the gist trims

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /wwdc/ was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address>Apache Server at developer.apple.com Port 80</address>
</body></html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment