import urllib.request
import time
price = 99.99
while price > 4.74:
time.sleep(900)
page = urllib.request.urlopen("http://www.beans-r-us.biz/prices.html")
text = page.read().decode("utf8")
where = text.find('>$')
start_of_price = where + 2
end_of_price = start_of_price + 4
price = float(text[start_of_price:end_of_price])
print ("Buy!")Shouldn't time.sleep(900) appear at the end of the loop so the program immediately retrieves a price to check if another iteration of the loop is actually needed?
import urllib.request
import time
price = 99.99
while price > 4.74:
page = urllib.request.urlopen("http://www.beans-r-us.biz/prices.html")
text = page.read().decode("utf8")
where = text.find('>$')
start_of_price = where + 2
end_of_price = start_of_price + 4
price = float(text[start_of_price:end_of_price])
time.sleep(900)
print ("Buy!")Just wondering about the positioning of the .sleep delay.
This post has been edited by Nathan King: 06 February 2012 - 01:55 AM


















