Extracting a row from a table from a url
<p>I want to download EPS value for all years (Under Annual Trends) from the below link.
<a href="http://www.bseindia.com/stock-share-price/stockreach_financials.aspx?scripcode=500180&amp;expandable=0" rel="nofollow">http://www.bseindia.com/stock-share-price/stockreach_financials.aspx?scripcode=500180&amp;expandable=0</a></p>

<p>I tried using Beautiful Soup as mentioned in the below answer.
<a href="http://stackoverflow.com/questions/17196018/extracting-table-contents-from-html-with-python-and-beautifulsoup">Extracting table contents from html with python and BeautifulSoup</a>
But couldn't proceed after the below code. I feel I am very close to my answer. Any help will be greatly appreciated.</p>

<pre><code>from bs4 import BeautifulSoup
import urllib2
html = urllib2.urlopen("http://www.bseindia.com/stock-share-price/stockreach_financials.aspx?scripcode=500180&amp;expandable=0").read()
soup=BeautifulSoup(html)
table = soup.find('table',{'id' :'acr'})
#the below code wasn't working as I expected it to be
tr = table.find('tr', text='EPS')
</code></pre>

<p>I am open to using any other language to get this done</p>

<p>The text is in the <em>td</em> not the <em>tr</em> so get the <em>td</em> using the text and then call <em>.parent</em> to get the <em>tr</em>:</p>

<pre><code>In [12]: table = soup.find('table',{'id' :'acr'})

In [13]: tr = table.find('td', text='EPS').parent

In [14]: print(tr)
&lt;tr&gt;&lt;td class="TTRow_left" style="padding-left: 30px;"&gt;EPS&lt;/td&gt;&lt;td class="TTRow_right"&gt;48.80&lt;/td&gt;
&lt;td class="TTRow_right"&gt;42.10&lt;/td&gt;
&lt;td class="TTRow_right"&gt;35.50&lt;/td&gt;
&lt;td class="TTRow_right"&gt;28.50&lt;/td&gt;
&lt;td class="TTRow_right"&gt;22.10&lt;/td&gt;
&lt;/tr&gt;
In [15]: [td.text for td in tr.select("td + td")]
Out[15]: [u'48.80', u'42.10', u'35.50', u'28.50', u'22.10']
</code></pre>

<p>Which you will see exactly matches what is on the page.</p>

<p>Another approach would be to call <em>find_next_siblings</em>:</p>

<pre><code>In [17]: tds = table.find('td', text='EPS').find_next_siblings("td")

In [18]: tds
Out[19]: 
[&lt;td class="TTRow_right"&gt;48.80&lt;/td&gt;,
 &lt;td class="TTRow_right"&gt;42.10&lt;/td&gt;,
 &lt;td class="TTRow_right"&gt;35.50&lt;/td&gt;,
 &lt;td class="TTRow_right"&gt;28.50&lt;/td&gt;,
 &lt;td class="TTRow_right"&gt;22.10&lt;/td&gt;]
In [20]: [td.text for td in tds]
Out[20]: [u'48.80', u'42.10', u'35.50', u'28.50', u'22.10']
</code></pre>

python html web-scraping beautifulsoup