html的一部分是:
<p class="more">
<span>S</span><br />
<input type="radio" name="rt0" value="0/0/S" onclick='showEI(this,"0", "0", "","S")'/>
¥1140<br />
<span class="seatNum">>9</span>
</p>
然后我得到¥1140
的xpath:
price = etree_html.find('.//*[@id="result_table"]/tbody/tr[2]/td[8]/text')
// print price
我能为这种情况做些什么?
答案 0 :(得分:0)
html的部分是:
<p class="more">
<span>S</span><br />
<input type="radio" name="rt0" value="0/0/S" onclick='showEI(this,"0", "0", "","S")'/>
¥1140<br />
<span class="seatNum">>9</span>
</p>
答案 1 :(得分:0)
html = """<p class="more">
<span>S</span><br />
<input type="radio" name="rt0" value="0/0/S" onclick='showEI(this,"0", "0", "","S")'/>
¥1140<br />
<span class="seatNum">>9</span>
</p>"""
import re
pattern = re.compile('<input type="radio" name="rt0".*?/>(.*?)<br />', re.DOTALL)
price = pattern.findall(html)[0].strip() #the strip command is for clearing '\n' characters and whitespaces...
print price
它有效......