Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This python script queries iTunes update url to see if iPhone OS 3.0 has been released for the iPhone 3G
import urllib2
import re
from time import sleep
class PageScraper(object):
This class scrapes a url for a string, can be used with a loop.
def __init__(self, url, string=''):
self.url = url
self.string = string = ''
self.request = None
def pull(self):
This method pull's the request and saves it as
if self.request == None:
self.request = urllib2.Request(self.url)
try: = urllib2.urlopen(self.request).read()
except urllib2.HTTPError: = ''
def search(self):
Search for a string in
return self.string in
def loop(self, delay=5.0):
Loop until the string is found.
while 1:
return True
if __name__ == "__main__":
update = PageScraper('', 'iPhone1,2_3.0_7A341')
if update.loop(delay=10.0):
print 'iPhone 3G 3.0 Update found'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment