python spider如何获得输入无线电的价值

时间:2016-07-18 09:38:34

标签: jquery python input radio elementtree

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

resurl是None

我能为这种情况做些什么?

2 个答案:

答案 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

它有效......