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

BCVisin

Well-known member
Nov 8, 2012
48
0
0
Visit site
So I wrote a quick python script this morning that I will leave running all day that will check both the Nexus 8GB and Nexus 16GB pages to see if anything on the pages has changed (MD5 Hash). If it has, it will email you as soon as the page changes. I wrote this so I don't have to sit there all day killing my F5 key. :) Here's the code:

Code:
import urllib
import hashlib
import time
import smtplib
import string

google_pages = {'https://play.google.com/store/devices/details?id=nexus_4_8gb':'6563c52c9711cb614c9daffdc9c55ee5', 'https://play.google.com/store/devices/details?id=nexus_4_16gb':'1aab1c70346b85075c0c63166c044eb7'}

count = 0

while True:
	count += 1
	if not count % 60:
		print 'Ran: %s' % count
	time.sleep(30)
	for google_page in google_pages.keys():
		page_file = urllib.urlopen(google_page)
		page_html = page_file.read()
		page_md5 = hashlib.md5(page_html).hexdigest()
		if page_md5 != google_pages[google_page]:

			#MAKE SURE TO REPLACE THE LINE BELOW WITH YOUR EMAIL
			email = 'youremail@example.com'

			server = smtplib.SMTP('localhost')

			msg = string.join((
				"From: %s" % email,
				"To: %s" % email,
				"Subject: %s" % 'NEXUS 4 ON SALE',
				"",
				"NEXUS 4 ON SALE! MD5 %s DOES NOT MATCH %s\n\n%s" % (page_md5, google_pages[google_page], google_page)
				), "\r\n")

			server.sendmail(email, email, msg)
			server.quit()
			exit()
 

BCVisin

Well-known member
Nov 8, 2012
48
0
0
Visit site
Not to take away from what you did (I thought of doing the same with a PHP app), but Chrome has something like this in an app already.

Here: http://forums.androidcentral.com/google-nexus-4/224271-small-tip-those-staying-up-tonight.html

Cool, good to know. I just whipped that little script up in about 5 min...I am a python programmer as my day job, and I thought this would be a more productive use of my time than getting distracted from my work constantly throughout the day. Thanks for the tip though! I am sure that plugin will help the non-programmers out there.

-Blake
 

BCVisin

Well-known member
Nov 8, 2012
48
0
0
Visit site
You may not, but I do. This is the first phone I have bought since the 3GS came on sale...and I am really excited for it.
 

mzanette

Zee
Aug 22, 2012
826
14
18
Visit site
You may not, but I do. This is the first phone I have bought since the 3GS came on sale...and I am really excited for it.

I understand, I just find it funny that people are so excited they need to order this thing the moment it's available. It's just a phone after all. Good luck to you! I wonder if all this hype is truly indicative of how successful the N4 will be or is it just a small bunch of people from Android forums? Would be cool if the Nexus 4 was a huge success.
 

Ricky2009

Well-known member
Oct 31, 2012
258
0
0
Visit site
I understand, I just find it funny that people are so excited they need to order this thing the moment it's available. It's just a phone after all. Good luck to you! I wonder if all this hype is truly indicative of how successful the N4 will be or is it just a small bunch of people from Android forums? Would be cool if the Nexus 4 was a huge success.
Id think it proabably just the android forums thing. But hopfully it is GREAT SUCCESS! Maybe add alittle fuel to the fire and make the next one even better
 

BCVisin

Well-known member
Nov 8, 2012
48
0
0
Visit site
Ya, I get that this isn't "SUCH" a big deal. Like I wouldn't stand in line over night to get this phone the moment it comes on sale, but since I am an uber nerd and it only took me a few minutes to write that script I thought it would be fun to post it up for any other uber nerds who wanted it. Although I don't think this phone will change my world, I am sure carrying around something better than the 3GS will be a little life changing. I do hope it will be a great success as well, but I really have no idea what demand is. I'm also stoked for the T-Mobile $30/month prepay plan.

-Blake
 

mzanette

Zee
Aug 22, 2012
826
14
18
Visit site
Ya, I get that this isn't "SUCH" a big deal. Like I wouldn't stand in line over night to get this phone the moment it comes on sale, but since I am an uber nerd and it only took me a few minutes to write that script I thought it would be fun to post it up for any other uber nerds who wanted it. Although I don't think this phone will change my world, I am sure carrying around something better than the 3GS will be a little life changing. I do hope it will be a great success as well, but I really have no idea what demand is. I'm also stoked for the T-Mobile $30/month prepay plan.

-Blake

This phone will be night and day with that 3GS man. I currently have the iPhone 4 and this feels long in the tooth. I can only imagine the 3GS.
 

BCVisin

Well-known member
Nov 8, 2012
48
0
0
Visit site
Copy and paste it into a file in your home directory. I called mine "nexus4_page_check.py" Then open a terminal (it should open you in your home direcotry) and type the command "python nexus4_page_check.py" and hit enter. Leave the terminal open to let it continue running. If you close the terminal, it will stop the script running. It runs in a loop every 30 seconds and outputs the count every 60 times it loops (so every 30 minutes). Here is what mine looks like running in a terminal right now:

Code:
blake@blake-M4600:~/workspace/ovg$ python nexus4_page_check.py 
Ran: 60
Ran: 120
Ran: 180
Ran: 240
(it has been running for over 2 hours)

I'm on Ubuntu 12.10

hope that helps!

-Blake
 

BCVisin

Well-known member
Nov 8, 2012
48
0
0
Visit site
Oh, also you need to change line 23 with your email address:

Code:
#MAKE SURE TO REPLACE THE LINE BELOW WITH YOUR EMAIL
email = 'youremail@example.com'

Let me know if you need any more help!

-Blake
 

blitz118

Well-known member
Apr 22, 2010
618
39
0
Visit site
why are so many people against a little bit of fun.i bet you go round popping balloons and beating puppies with kittens.

I'm not against it, it?s just funny watching people get all excited about the phone. I'm still undecided myself, but I did enter my email address with play store to contact me when the phone is available in case I change my mind. $350 is good price for the phone.:)
 

c_hri_s

Well-known member
Nov 9, 2012
48
0
0
Visit site
If you're in the UK you need to use these values in place of those the OP gave (which I assume were for the US store):

Code:
google_pages = {'https://play.google.com/store/devices/details?id=nexus_4_8gb':'
c6ffd72027eb76ef451249af697144ad', 'https://play.google.com/store/devices/detail
s?id=nexus_4_16gb':'ead983f8873540b866b7670a86b90b4f'}

Script running on my Raspberry Pi - I'll leave it there all night and set up a filter to ping the email notification extra loud if the subject is Nexus!
 

Trending Posts

Forum statistics

Threads
942,410
Messages
6,913,956
Members
3,158,400
Latest member
m1000