<html xmlns="hyyp://www.w3.org/1999/xhtml">
<head>_</head>
<body>
<form name="Main Form" method="post" action="HTMLReport.aspx?ReportName=...">
<div id="Whole">
<div id="ReportHolder">
<table xmlns:msxsl="urn:schemeas-microsoft-com:xslt" width="100%">
<tbody>
<tr>
<td>_</td>
<td>LIVE</td>
and the data I need is here between <td> </td>
现在,到目前为止我的代码是:的Python - 硒 - webscrape的xmlns表
import time
from selenium import webdriver
chromeOps=webdriver.ChromeOptions()
chromeOps._binary_location = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
chromeOps._arguments = ["--enable-internal-flash"]
browser = webdriver.Chrome("C:\\Program Files\\Google\\Chrome\\Application\\chromedriver.exe", port=4445, chrome_options=chromeOps)
time.sleep(3)
browser.get('website')
elem=browser.find_element_by_id('MainForm')
el=elem.find_element_by_xpath('//*[@id="ReportHolder"]')
代码的最后两行只是真的是我想知道我怎么路径可能的XPath breaksdown前走。尝试xpath到超出此点的任何内容都会导致noSuchElementException。
任何人都可以向我解释我如何从表格中抽取数据吗?
我目前的想法是,也许我必须通过“东西”到一个XML树API,并通过它访问它。虽然我不知道如何捕捉它。
如果任何人都可以给我下一步它将不胜感激,感觉有点像我在黑暗的房间里拿着蜡烛此刻。
为了澄清,如果你使用了一个xpath,比如:'driver.find_element_by_xpath(“// div [@ id ='ReportHolder']/table/tbody/tr”)'你正在接收异常? –
是的,这是正确的。 在我的示例中: el = browser.find_element_by_xpath('// * [@ id =“ReportHolder”]/table/tbody/tr') 产生noSuchElementException – Phoenix