Tuesday, May 29, 2018

Yahoo Finance Stock Price Scraper - mosaic of 40 Brazilian stocks

  After pandas.datareader deprecated Yahoo Finance, I did a web scraper using Beautiful Soup to get stock prices from there, but there are limitations : Its only able to get about 100 days minus every day the a dividend (if any) is paid for a particular stock. 

  Bear in mind that although Yahoo Finance adjusts the price for dividends It did not adjust splits (at least for Brazilian stocks). 

  It can be easily adjust for stocks of other countries covered By Yahoo F. simply altering the local stock country code (line 93). 

>> Python 3 code on Gist <<

Postscript : 

  • 05/31 - The code has stopped working on - Yahoo has changed the html code for the page. Working on a new code.
  • 06/01 - The code was updated today - adapted to new html design of Yahoo Finance.
  • 06/07 - Minor adjustment on the page requires a one line(40) change to : " for n in range(0, len(d)-1) :" - code was updated today.