Extract data from an HTML tag which has specific attributes
<pre><code>&lt;tr bgcolor="#FFFFFF"&gt;
    &lt;td class="tablecontent" scope="row" rowspan="1"&gt;
        &lt;a href="http://netprofile-us2/netprofile/npIndex.do?cpyKey=80823"&gt;ZURICH AMERICAN INSURANCE COMPANY&lt;/a&gt;
    &lt;/td&gt;
    &lt;td class="tablecontent" scope="row" rowspan="1"&gt;
        FARMERS GROUP INC (14523)
    &lt;/td&gt;
    &lt;td class="tablecontent" scope="row"&gt;
        znaf
    &lt;/td&gt;
    &lt;td class="tablecontent" scope="row"&gt;
        anhm
    &lt;/td&gt;
&lt;/tr&gt;
</code></pre>

<p>I have an HTML document which contains multiple <code>tr</code> tags. I want to extract the <code>href</code> link from the first <code>td</code> and data from third <code>td</code> tag onwards under every <code>tr</code> tag. How can this be achieved?</p>

<p>You can use css selector <code>nth-of-type</code> to navigate through the <code>td</code>s</p>

<p>Here's a sample"</p>

<pre><code>soup = BeautifulSoup(html, 'html.parser')
a = soup.select('td:nth-of-type(1) a')[0]
href = a['href']
td = soup.select("td:nth-of-type(3)")[0]
text = td.get_text(strip=True)
</code></pre>

python python-2.7 beautifulsoup