Python selenium或Beauty soup从动态表单元格获取数据
我试图在web表中获取一个字段的文本,数据字段在表单元格及其动态中。 我已经在下面试过了Python selenium或Beauty soup从动态表单元格获取数据,python,selenium,beautifulsoup,Python,Selenium,Beautifulsoup,我试图在web表中获取一个字段的文本,数据字段在表单元格及其动态中。 我已经在下面试过了 1- get attributes using x path , innerText , innerHTML, textContent, value, resulting None or Html. 2 - beautiful soup - Returning HTML and with lxml returning none HTML: <td> <div class="fields
1- get attributes using x path , innerText , innerHTML, textContent, value, resulting None or Html.
2 - beautiful soup - Returning HTML and with lxml returning none
HTML:
<td>
<div class="fieldsbox" id="xfe54" style="visibility: visible;">
<input readonly="" isoutputcontrol="true" xformstype="output" id="policy_number"
xql="tns:CHDRNUM" databoundelement="true" __parent="tblResults" class="input output"
absolutexpath="tns:CHDRNUM" doebivalidate="false" title="Value for Policy No." style=""
ref="tns:CHDRNUM" _intable="true"></div>
</td>
通过XPATH
previous_Claim_Policy = crom_driver.find_element_by_xpath(xpath_string).get_attribute('value')
previous_Claim_Policy_inner_text = crom_driver.find_element_by_xpath(xpath_string).get_attribute('innerText')
previous_Claim_Policy_txt = crom_driver.find_element_by_xpath(xpath_string).text
previous_Claim_Policy_txt_content = crom_driver.find_element_by_xpath(xpath_string).get_attribute('textContent')
previous_Claim_Policy_txt_html_inner = crom_driver.find_element_by_xpath(xpath_string).get_attribute('innerHTML')
我尝试了完整的x路径,结果是得到了_attibute('value')
xpath_string='/html/body/div[2]/div[3]/div/div[2]/fieldset/div/div/div[1]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/input'您预期的输出是什么?
previous_Claim_Policy = crom_driver.find_element_by_xpath(xpath_string).get_attribute('value')
previous_Claim_Policy_inner_text = crom_driver.find_element_by_xpath(xpath_string).get_attribute('innerText')
previous_Claim_Policy_txt = crom_driver.find_element_by_xpath(xpath_string).text
previous_Claim_Policy_txt_content = crom_driver.find_element_by_xpath(xpath_string).get_attribute('textContent')
previous_Claim_Policy_txt_html_inner = crom_driver.find_element_by_xpath(xpath_string).get_attribute('innerHTML')