Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72443

extract text from second div by text beautifulsoup

$
0
0

A have below html code. Need to extract text4 based on "text3" value

<div class="main">
<ul>
<li>
<div class="1"> text1 </div>
<div class="2"> text2 </div>
</li>
<li>
<div class="1"> text3</div>
<div class="2"> text4</div>
</li>
</ul></div>

I used this code, but its not working. Am I missing something or there is simpler solution for this?

a.find_next_sibling('div')[0]
for a in soup.find_all('div', text='text3')

Viewing all articles
Browse latest Browse all 72443

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>