-
-
Save nagisa/ac0bb257a75976eff2cc to your computer and use it in GitHub Desktop.
wha.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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