[英]selenium or beautiful soup to get data from dynamic table cell
I am trying to get text of a field inside web table, data field is inside table cell and its dynamic.I am using python script for this task.我正在尝试获取 web 表内的字段文本,数据字段在表单元格内及其动态。我正在使用 python 脚本来完成此任务。 I have tried it through below
我已经通过下面尝试过
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: 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>
Beautiful soup美丽的汤
url = "https://cms.bharti-axagi.co.in/home/CMS/com/bagi/cms/Loginforms/CMS_LoginScreen.caf"
crom_driver.get(url)
time.sleep(5)
content = crom_driver.page_source
soup = bs(content, "html.parser")
data = soup.findAll("table", {"id": "CMS_CLAIMS_DETAILSTable"})
print(data)
Through XPATH通过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')
I tried by full x path and it worked out wiht get_attibute('value')我尝试了完整的 x 路径,它通过 get_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'' 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''
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.