Skip to content

Instantly share code, notes, and snippets.

@fission6
Created August 22, 2011 16:03
Show Gist options
  • Save fission6/1162763 to your computer and use it in GitHub Desktop.
Save fission6/1162763 to your computer and use it in GitHub Desktop.
newegg touchpad watcher
import urllib2
from time import sleep
from datetime import datetime
from subprocess import Popen
PRODUCT_URL = "http://content.newegg.com/LandingPage/ItemInfo4ProductDetail.aspx?Item=N82E16834158004"
def check():
"""
Check product url and look for 'Out of Stock' in the specified xpath.
If not found, then the product maybe in stock, so BEEP.
"""
time_check = datetime.now()
page = urllib2.urlopen(PRODUCT_URL).read()
is_lowered = '"finalPrice":"399.99"' not in page
if is_lowered:
print time_check, "Touchpad has possibly lowered price"
#Show a zenity popup
Popen("zenity --info --text 'HP Touchpad may have lower price'", shell=True)
else:
print time_check, "Touch pad has not lowered price"
def main():
while True:
check()
sleep(30)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment