Skip to content

Instantly share code, notes, and snippets.

@abh1nav
Last active December 11, 2015 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abh1nav/4551462 to your computer and use it in GitHub Desktop.
Save abh1nav/4551462 to your computer and use it in GitHub Desktop.
Automatically scrape the Play Store to check if the Nexus4 is in stock.
import boto
import requests
urls = { "8GB Nexus4": "https://play.google.com/store/devices/details?id=nexus_4_8gb", "16GB Nexus4": "https://play.google.com/store/devices/details?id=nexus_4_16gb" }
sold_out_text = '<span class="hardware-price-description hardware-large-print hardware-sold-out">Sold out</span>'
headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11" }
for url in urls:
r = requests.get(urls[url], headers=headers)
if r.status_code == 200 and sold_out_text not in r.text:
# Send AmazonSNS alert
print "%s is in stock!!!" % url
sns = boto.connect_sns()
sns.publish("<MY_SNS_ARN>", "In Stock", "In Stock")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment