jeudi 2 juillet 2015

python comparing an integer value with value obtained from pattern matching

i have made a small program to set an notification to sell or buy apple stock,but i cannot compare values the user input as a limit for buying or selling with the actual value obtained from pattern matching

import urllib
import re
import time
import winsound
import os


 a=0
 regex = '<span id="yfs_l84_aapl">(.*?)</span>'
 pattern = re.compile(regex)
 url = urllib.urlopen("http://ift.tt/1FXDr4S")
 httppage = url.read()
 page = re.findall(pattern,httppage)
 print"\n HELLO,TODAYS APPLE STOCK PRICE IS"+str(page)+"$....would you like    to set a limit to remaind you to buy and sell(press y or n)"
 val=raw_input()


 if(val=='y' or val=='Y'):
           a = raw_input("OK,great...\n\tEnter the BUYING limit := ") //values obtained from user
           a=int(a)
           b = raw_input("OK,great...\n\tEnter the SELLING limit := ")//values obtained from user
           b=int(b)
 else:
           print"OK may be tomorrow,bye!"
           a=0
           time.sleep(4)
           exit(0)




 while(a):
                       regex = '<span id="yfs_l84_aapl">(.*?)</span>'
                       pattern = re.compile(regex)
                       url = urllib.urlopen("http://ift.tt/1FXDr4S")
                       httppage = url.read()
                       page = re.findall(pattern,httppage)
                       comp=page  /*the value obtained from the regular expression 

                       os.system('cls')
                       print "\n\n\n\t**************************************************\n\n\n"

                       print "\t"+str(page) //displaying the result

                       print "\n\n\n\t**************************************************\n\n\n"
                       comp = map(int, comp)
                       while(comp<=a):       /*i cannot make the value obtained by user to compare with value obtained from the pattern result*/
                                        winsound.Beep(900,500)
                                        print "hello,its time to buy the stock:)"

                       while(comp>=b):
                                        winsound.Beep(900,500)
                                        print "hello,its time to sell the stock:)"




Aucun commentaire:

Enregistrer un commentaire