tr class=tr-heji style=display table-row; tdGSPure Circ-eGFPtd tdR0701td td1gtd td class=shuliang1td td class=jiage100td td class=proZhe
可以使用以下代码判断td下是否有input标签,并获取其值:
from bs4 import BeautifulSoup
html = '''
<tr class="tr-heji" style="display: table-row;">
<td>GSPure Circ-eGFP</td>
<td>R0701</td>
<td>1g</td>
<td class="shuliang">1</td>
<td class="jiage">100</td>
<td class="proZhekou">¥<input type="text" value="0" style="width: 50px;"></td>
<td class="heji">¥99.00</td>
</tr>
'''
soup = BeautifulSoup(html, 'html.parser')
td = soup.find('td', class_='proZhekou')
input_tag = td.find('input')
if input_tag:
value = input_tag['value']
print(value)
else:
print('No input tag found')
输出结果为:
0
``
原文地址: http://www.cveoy.top/t/topic/h1A2 著作权归作者所有。请勿转载和采集!