Python script to notify you the minute the Nexus 4 page goes on sale

Thanks BCVisin. i've just PM'd you my email. Is your script able to check Google Play Stores from different countries? May need a VPN connection for this.
 
How did you generate the md5 hash? This may be a n00b question but I thought md5 hash's were generated from a string. Did you simply copy the url source and get it that way? Thanks!
 
How did you generate the md5 hash? This may be a n00b question but I thought md5 hash's were generated from a string. Did you simply copy the url source and get it that way? Thanks!

So the python class method urllib.urlopen() returns a file like object of the URL page. I then assign it to a variable string by calling the read() method on that object. So yes, it is reading the entire source of the page as a string. I then use hashlib to get an MD5 of the source of that page, and compare it against a known MD5 of that page. If it changed, something in the HTML source changed. This will likely not work on pages who's source is changed dynamically by javascript, but in this case google changed the source of the pages as soon as it went on sale. I as well as the others that I sent the email to got notified as soon (within 30 seconds as I had this in a 30 second loop) as the N4 came on sale. It worked! I got mine in the first batch shipped out since I got notified less than a minute after the page changed.

Reference:
20.5. urllib ? Open arbitrary resources by URL — Python v2.7.3 documentation
14.1. hashlib ? Secure hashes and message digests — Python v2.7.3 documentation

-Blake
 
Just added this to my crontab :)

MAILTO=you@youremail.com
*/20 * * * * curl -s 'https://play.google.com/store/devices/details?id=nexus_4_16gb' | grep 'Sold out' > /dev/null || echo "NEXUS ON SALE!"
 
Maybe it would be more efficient if your script just searched for "We are out of inventory" on the nexus pages and report when it does NOT show up any more? You'll be immune to other changes that way.
 

Trending Posts

Forum statistics

Threads
956,814
Messages
6,970,130
Members
3,163,628
Latest member
lostcowboy