How to read dynamic values on a site?
Question: What's the best way to scrape dynamic data from a site?

I want to read the ticker value on the top of this page:

[https://www.google.com/finance?q=INDEXBOM%3ASENSEX&ei=M1B1U_iEG8OPkAWhuYGIDA](https://www.google.com/finance?q=INDEXBOM%3ASENSEX&ei=M1B1U_iEG8OPkAWhuYGIDA)

using python. I can't seem to be able to figure a clear way out.


Answer: Since Google Finance API was [shut
down](https://developers.google.com/finance/), here's an option to get it via
[`urllib2`](https://docs.python.org/2/library/urllib2.html) and
[`BeautifulSoup`](https://beautiful-soup-4.readthedocs.org/en/latest/):

    
    
    >>> from urllib2 import urlopen
    >>> from bs4 import BeautifulSoup
    >>> url = 'https://www.google.com/finance?q=INDEXBOM%3ASENSEX&ei=M1B1U_iEG8OPkAWhuYGIDA'
    >>> soup = BeautifulSoup(urlopen(url))
    >>> soup.find('div', id='price-panel').span.text.strip()
    u'25,050.96'
    

Just as an alternative, consider using [Yahoo Finance
API](https://finance.yahoo.com/q?s=API), see
[`ystockquote`](https://pypi.python.org/pypi/ystockquote) module.

