Skip to content

Instantly share code, notes, and snippets.

@dakk
Created July 4, 2016 15:36
Show Gist options
  • Save dakk/c814f93a918ef9381d3ef0e5b454acb5 to your computer and use it in GitHub Desktop.
Save dakk/c814f93a918ef9381d3ef0e5b454acb5 to your computer and use it in GitHub Desktop.
Send a desktop notification if a new house is available on Subito.it
import requests
import time
from gi.repository import Notify
Notify.init("getCase")
def getCase ():
d = requests.get ("http://www.subito.it/annunci-sardegna/affitto/appartamenti/cagliari/cagliari/?pe=5").text
return int (d.split ("Tutti: ")[1].split ('<')[0])
att = 0
while True:
v = getCase ()
if att != 0 and v != att:
Notify.Notification.new("Case disponibili: " + str(v) + " (" + str (v-att) + ")").show()
att = v
if att == 0:
att = v
Notify.Notification.new("Case disponibili: " + str(att)).show()
print "Case disponibili:", att
time.sleep (60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment