Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This python script parses all feeds and searches for predefined words in each item title. If it finds a match, it sends an instant message through Pushover ( It also logs all the posted items in text files per category. More information in
import feedparser #need manual installation. Doesn't come with Python.
import os
import httplib #used by pushover
import urllib #used by pushover
# Linux:
folderPath = '/home/YOUR_USERNAME/Scripts/Support_Files/Woot/'
# Just items:
#url = ""
# All woot feeds:
url = ""
alertsFile = folderPath+'alert_list.txt'
dealsFile = folderPath+'dealsgroup' #omit extension as it will be provided by the script.
def pushover(msg):
conn = httplib.HTTPSConnection("")
conn.request("POST", "/1/messages.json",
"message": msg,
}), { "Content-type": "application/x-www-form-urlencoded" })
def inItemsList(wootTitle, fileIndex):
''' Checks if the item currently in was previously entered in the item_list.txt file.
If it was not, it enters it and returns the inList flag as False (i.e. it wasn't previously in the
list of items). Otherwise, it returns the flag as True (i.e. it is already in the list)'''
fileStr = str(fileIndex)
with open(dealsFile+'-'+fileStr+'.txt', 'a+') as itemList: #it opens or creates a file in the form of dealsgroup-1.txt
lastLine = itemList.readlines()[-1].strip('\n')
except IndexError:
lastLine = ''
''' If the file is empty or does not exist, there will be an IndexError.
Then, an arbitraty value is assigned to lastLine so that the script continues
and the file is created'''
if wootTitle==lastLine:
return inList
# Main Script
def main():
parsedFeed = feedparser.parse(url)
entryIndex = 0
for entry in parsedFeed['entries']:
entryIndex += 1
# The feed only has one entry. Therefore, the data from index [0] is assigned.
title = entry['title']
soPercentage = entry['woot_soldoutpercentage']
price = entry['woot_price']
wootoff = entry['woot_wootoff']
except IOError:
print ('Variables could not be assigned based on parsed data')
if not inItemsList(title, entryIndex):
with open(alertsFile, 'r') as alertList:
for alertName in alertList:
alertName = alertName.strip('\n').strip('\r')
# '\r' should be used to remove carriage return on *nix systems.
print alertName
print title
if alertName in title:
print ('Item found in Alert List')
soPerInt = int(soPercentage)*100
body = "Title: %s \nPrice: %s \nSold Out Percentage: %s%% \nWoot Off? %s\n" % (title, price, str(soPerInt), wootoff)
print ('Sending message to pushover')
print ('Item not found in Alert List')
print ('Item already in Item List')
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment