Reputation: 111
I've tried this on different links and it would work but specifically on this link it won't work:
ticker = 'SBUX'
url = urlfetch.fetch('http://stockcharts.com/h-sc/ui?s=' + ticker +
'&p=D&yr=1&mn=0&dy=0&id=p97813671848')
# Parses the HTML
tree = etree.HTML(url.content)
# Converts the DOM into a string
result = etree.tostring(tree, pretty_print=True, method="html")
self.response.out.write(result)
I don't know why it cannot fetch the stockcharts link?
Could it be that stockcharts blocks google?
Upvotes: 0
Views: 233
Reputation: 5424
Weird. Seems to work with urllib though ...
ticker = 'SBUX'
uri = 'http://stockcharts.com/h-sc/ui?s=' + ticker + '&p=D&yr=1&mn=0&dy=0&id=p97813671848'
response = urllib2.urlopen(uri)
html = response.read()
Upvotes: 1