0
我想從這個網頁輸入的元素:的HtmlUnit和XPath無法檢索HTML元素
https://www.milanuncios.com/textos-del-anuncio/?demandax=n&c=131&idlocalidad=8&p=almeria&x=27&y=0
輸入本身是:
<input class="inputs campoGrande" name="marca" value="" maxlength="120" size="12" id="marca" tabindex="1" type="text">
我曾嘗試不同的方法,但我總是得到的是一個「零」參考:
HtmlInput inputZona = (HtmlInput) currentPage.getElementById("marca");
HtmlInput inputZona = (HtmlInput) currentPage.getFirstByXPath("//input[@name='marca']");
也試過JSoup,結果相同:-(
HTMLUnit和XPAth都無法獲取該項目。
這是怎麼回事?
由於提前,
何塞
請注意,該頁面是XHTML,因此您可以嘗試將其聲明爲默認名稱空間或通配符XPath,例如, // *:輸入 – chrisis
@chrisis,謝謝。我設法通過使用XPath(/ html/body/div/form ...)來使用絕對路徑。不明白爲什麼這是HTMLUnit未正確處理的唯一輸入項,但... – kankamuso