I want the program to keep running until the condition is met, but the global variable I have to control this seems to reset after I've run through the script once.
Here's my code:
from bs4 import BeautifulSoup
import urllib, re, winsound, time
url = 0
deal = 0
def main():
url = raw_input("Please enter url to watch: ")
deal = raw_input("Please enter the percent: ")
control(url, deal)
print "Done"
def control(addr, dealz):
html = watcher(addr)
percent = regex(html)
if percent >= dealz:
playNoise()
return
else:
print "Not yet..."
time.sleep(10)
control(url, deal)
def watcher(addr):
print addr
sock = urllib.urlopen(addr)
html = sock.read()
sock.close()
soup = BeautifulSoup(html)
percent = soup.find_all(id="productYoyo_Relative")
for item in percent:
product = str(item)
return product
def regex(product):
p = re.compile('.*-?(\d{2})%.*')
result = p.match(product)
return result.group(1)
def playNoise():
winsound.PlaySound('alert.wav', winsound.SND_FILENAME)
if __name__ == "__main__":
main()
url keeps getting reset to 0 after I've given it the value.

New Topic/Question
Reply



MultiQuote







|