Web Scraping Code to extract stock price

前端 未结 2 867
[愿得一人]
[愿得一人] 2020-12-12 06:00

I am creating a web scrapping python code (using 2.7.11) that extracts the stock price using symbol. I am not sure why this is not working. But it gives me this output:

2条回答
  •  感动是毒
    2020-12-12 06:33

    The string "yfs_l84" you are searching for is not contained in the HTML returned by yahoo. So

    where=text.find("yfs_l84")
    

    leaves where to be -1. So your slice text[start:end] will always be text[6:11] and cut YPR h out of the page source:

    
    
    
        ...
    

提交回复
热议问题