Skip to content

Instantly share code, notes, and snippets.

@nagisa

nagisa/running Secret

Created October 5, 2011 16:58
Show Gist options
  • Save nagisa/ac0bb257a75976eff2cc to your computer and use it in GitHub Desktop.
Save nagisa/ac0bb257a75976eff2cc to your computer and use it in GitHub Desktop.
wha.py
[nagisa@godbox Desktop]$ python wha.py
Would you like to see the price now (Y/N) ?n
Price now is: 6.02
Price now is: 6.02
Price now is: 6.13
Price now is: 6.13
Price now is: 6.13
Price now is: 6.13
Price now is: 5.47
Buy!!
import urllib.request
import time
def get_price() :
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
print("Price now is: "+text[start_of_price:end_of_price])
return float(text[start_of_price:end_of_price])
price_now = input("Would you like to see the price now (Y/N) ?")
if price_now == "y":
print(get_price())
else:
price = get_price()
while price>6.00:
time.sleep(30)
price = get_price()
print("Buy!!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment