Last active
December 11, 2015 05:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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