Created
January 12, 2014 22:11
-
-
Save kwgotrik/8391334 to your computer and use it in GitHub Desktop.
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
# Scraping the Safeway Ice Cream deals for store 676, adjust with storefinder for yours | |
# Notification via Pushover, can run with a cron job on server | |
# url: 'http://m.safeway.com/WeeklySpecials/Index?filterType=ByCategory&selectedCategory=none&storeId=676' | |
# use this to find the other categories | |
# thanks ccc for the input! | |
import bs4, requests, console | |
console.clear() | |
def writePushNotification(message): | |
pushover_url = 'https://api.pushover.net/1/messages.json' | |
payload = { 'token' : 'your_token', | |
'user' : 'your_userID', | |
'message' : message } | |
return requests.post(pushover_url, data=payload).text | |
items_url = 'http://m.safeway.com/WeeklySpecials/GetCategoryItems' | |
payload = {'storeID' : '676', 'filter' : 'ByCategory', 'categoryName' : 'Frozen Foods'} | |
items = requests.post(items_url, data=payload) | |
soup = bs4.BeautifulSoup(items.text) | |
products = soup.findAll('div', {'class' : 'one-item-div'}) | |
pushme =[] | |
for product in products: | |
title = product.find('h3', {'class' : 'sw-heading'}).text | |
price = product.find('div', {'class' : 'red bold'}).text.strip() | |
if 'Ice Cream' in title: | |
string = title.replace('Ice Cream', '- ') + price | |
if not string in pushme: | |
pushme.append(string) | |
if pushme: | |
s = '\n'.join(pushme) | |
print(s) | |
# writePushNotification(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment