Google Finance Network Error
Contents |
von GoogleAnmeldenAusgeblendete FelderNach Gruppen oder Nachrichten suchen
von GoogleAnmeldenAusgeblendete FelderNach Gruppen oder Nachrichten suchen
von GoogleAnmeldenAusgeblendete FelderNach Gruppen oder Nachrichten suchen
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up page scraping to get prices from google finance up vote 4 down vote favorite 4 I am trying to get stock prices by scraping google finance pages, I am doing this in python, using urllib package and then using regex to get price data. When I leave my python script running, it works initially for some time (few minutes) and then starts throwing exception [HTTP Error 503: Service Unavailable] I guess this is happening because on web server side it detects frequent page updates as a robot and throws this exception after a while.. is there a way around this, i.e. deleting some cookie or creating some cookie etc.. or even better if google gives some api, I want to do this in python because the complete app in python, but if there is nothing available in python to do this, I can consider alternatives. This is my python method that I use in loop to get data ( with few seconds of sleep I call this method in loop) def getPriceFromGOOGLE(self, symbol): """ gets last traded price from google for given security """ toReturn = 0.0 try: base_url = 'http://google.com/finance?q=' req = urllib2.Request(base_url + symbol) content = urllib2.urlopen(req).read() namestr = 'name:\"' + symbol + '\",cp:(.*),p:(.*),cid(.*)}' m = re.search(namestr, content) if m: data = str(m.group(2).strip().strip('"')) price = data.replace(',','') toReturn = float(price) else: print 'ERROR ' + str(symbol) + ' --- ' + str(content) except Exception, exc: print 'Exc: ' + str(exc) finally: return toReturn python screen-scraping urllib stockquotes google-finance share|improve this question asked Apr 12 '11 at 14:32 user424060 4071818 1 Read 5.3 from TOS –J.F. Sebastian Apr 12 '11 at 15:02 Agreed...and the API is an "interface that is provided by Google" –AJ. Apr 12 '11 at 15:11 Is this legal? I mean to do web scrapping on google and yahoo? –JohnPristine Dec 17 '13 at 17:06 add a comment| 4 Answers 4 a