if i have an html code like this
<div class="new_info_next">
<input type="hidden" value="133" id="new_id" class="new_id">
<input type="hidden" value="0" id="default_pe" class="default_pe">
</div>
and i want to get only 133
in input
the first line i try this code using BeautifulSoup4
info = soup.find_all("div", {"class": "new_info_next"})
for inpu in info:
for inpu1 in inpu.select('input'):
print inpu1 .get('value')
but the output was
133
0
how to get only 133
use soup.find()
by default it will get you the first element matching, so you could do:
info = soup.find("div", {"class": "new_info_next"})
and info.get('value') should be 133
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With