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
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!

Thanks Chris,

You are correct in the fact that the URL and page I posted is the US version. Thanks for getting the other's the MD5's for the UK! So that confirms that the US and UK sites are different. That means that the times they release the ability to order could be different for US/UK/AU.

-Blake
 

c_hri_s

Well-known member
Nov 9, 2012
48
0
0
Visit site
It'll be the price - we use the same URL but it directs to a country specific page. We see the device priced in GBP not USD.
 

BCVisin

Well-known member
Nov 8, 2012
48
0
0
Visit site
Just got the alert, but I see no way to order it. Guess they are prepping for launch. The updated MD5's are:

Code:
google_pages = {'https://play.google.com/store/devices/details?id=nexus_4_8gb':'535ae9c50d6448021c806eb5308c38d3', 'https://play.google.com/store/devices/details?id=nexus_4_16gb':'3d43313ef3607e5758c5a7c9f61f1d87'}
 

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,569
2,797
113
Visit site
LOL. Internet high 5 for this man.

I'm doing it a bit differently with lynx, the cat command, and grep. Your way is much more efficient :)
 

six8

Well-known member
Apr 28, 2012
155
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()

*mindblown

Sent from my SAMSUNG-SGH-I317 using Tapatalk 2
 

BCVisin

Well-known member
Nov 8, 2012
48
0
0
Visit site
Anyone who wants can send/message me their email address and I can easily add it to my script so you don't have to run it. You will be notified any time the Nexus 4 page (8 or 16GB) changes.

-Blake
 

jeremydc

Well-known member
Nov 12, 2012
132
0
0
Visit site
Quick question. When a change occurs and the window is minimized, will there be a notification sound/ blinking? About to watch MNF
 

trter10-imore

ThunderboltTool Developer
Nov 24, 2011
738
116
0
Visit site
I'm not too sure they'll update the webpage itself but rather where it gets its info from, kind of like an embed.

edit- just took a look at the html and it is actually hard-coded in the webpage.

Code:
<div class="coming-soon-text">Coming Soon</div><div class="sign-up-text hardware-small-print">Sign up to be notified by email when Nexus 4 (8GB) becomes available.</div><form id="backorder-signup-form" method="post" enctype="multipart/form-data" action="https://services.google.com/fb/forms/playnexusoptin/" target="_blank"><input type="text" name="email" id="backorder-signup-email" class="sign-up-form hint-textbox" label="Email address" /><div class="hardware-form-submit-border"><input type="submit" id="backorder-submit-button" class="hardware-form-submit border-box" value="Notify me"/>
 

yukichi

Well-known member
Nov 13, 2012
55
0
0
Visit site
I tried running it and got an error with this line:

server = smtplib.SMTP('localhost')

The error when I execute the script is:

Traceback (most recent call last):
File "nexuscheck.py", line 25, in <module>
server = smtplib.SMTP('localhost')
File "C:\Python27\lib\smtplib.py", line 249, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python27\lib\smtplib.py", line 309, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python27\lib\smtplib.py", line 284, in _get_socket
return socket.create_connection((port, host), timeout)
File "C:\Python27\lib\socket.py", line 571, in create_connection
raise err
socket.error: [Errno 10061] No connection could be made because the target machi
ne actively refused it

How do I fix this?
 

BCVisin

Well-known member
Nov 8, 2012
48
0
0
Visit site
I tried running it and got an error with this line:

server = smtplib.SMTP('localhost')

The error when I execute the script is:

Traceback (most recent call last):
File "nexuscheck.py", line 25, in <module>
server = smtplib.SMTP('localhost')
File "C:\Python27\lib\smtplib.py", line 249, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python27\lib\smtplib.py", line 309, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python27\lib\smtplib.py", line 284, in _get_socket
return socket.create_connection((port, host), timeout)
File "C:\Python27\lib\socket.py", line 571, in create_connection
raise err
socket.error: [Errno 10061] No connection could be made because the target machi
ne actively refused it

How do I fix this?

It's because you are not running a smtp server (postfix or sendmail) on your local computer. You can either figure it out by changing the code like this: Kutuma's Ramblings: Sending emails via Gmail with Python

OR (better option) give me your email address, so my script will CC you when it emails me (probably at 12:00 AM PST tonight)

-Blake
 

yukichi

Well-known member
Nov 13, 2012
55
0
0
Visit site
It's because you are not running a smtp server (postfix or sendmail) on your local computer. You can either figure it out by changing the code like this: Kutuma's Ramblings: Sending emails via Gmail with Python

OR (better option) give me your email address, so my script will CC you when it emails me (probably at 12:00 AM PST tonight)

-Blake

I am curious on setting it up for my machine. Any equivalent to postfix or sendmail recommended for windows?
 

marty331

Well-known member
Jul 15, 2011
48
0
0
Visit site

Forum statistics

Threads
943,164
Messages
6,917,586
Members
3,158,854
Latest member
lindagibney