Skip to content Skip to sidebar Skip to footer

Web Scraping Information Other Than Price From Yahoo Finance In Python 3

I'm new to python so I apologize for any rookie mistakes. I followed a tutorial to scrape stock prices from python but after fixing it to work in python 3 when I tried to adapt it

Solution 1:

First I would suggest you to use BeautifulSoup instead of regex. And hope this example will help you finish your problem, even though it's python2.7:

>>>import urllib2>>>from bs4 import BeautifulSoup as bs4>>>html_file = urllib2.urlopen("http://finance.yahoo.com/q?s=goog&q1=1")>>>soup = bs4(html_file)>>>for price in soup.find(attrs={'id':"yfs_l84_goog"}):...print price... 
846.90
>>>

Solution 2:

Use Yahoo Finance's CSV format rather than HTML, then use CsvReader to parse the results.

For details on the CSV format, see here. However, Yahoo Finance URL has changed since that document was written. Use http://download.finance.yahoo.com instead of http://finance.yahoo.com.

Solution 3:

I am having the same problem and when I go to http://download.finance.yahoo.com, I get redirected to http://finance.yahoo.com, and it appears the CSV format link got shut down by Yahoo.

The issues seems to be that the url is too long and convoluted. Which maybe they did so we couldn't keep scrapping their data in this way. Is there a different way to go about this? I try scrapping from finance.msn.com as well, but ran into the same issue where the url is too convoluted and long.

Perhaps I just need to look for another finance site that is less known. I'll see what I can find.

Post a Comment for "Web Scraping Information Other Than Price From Yahoo Finance In Python 3"