Вопрос

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?

Это было полезно?

Решение

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()
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top