HtmlUnit 和 XPath 无法检索 HTML 元素

HtmlUnit and XPath fail to retrieve HTML element

我正在尝试从该网站获取输入元素:

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">

我尝试了不同的方法,但我总是得到一个 "null" 参考:

HtmlInput inputZona = (HtmlInput) currentPage.getElementById("marca");
HtmlInput inputZona = (HtmlInput) currentPage.getFirstByXPath("//input[@name='marca']");

也尝试了 JSoup,结果相同 :-(

HTMLUnit 和 XPAth 都无法获取项目。

这是怎么回事?

提前致谢,

何塞

此代码适用于最新版本的 HtmlUnit (2.28-SNAPSHOT)。

    public static void main(String[] args) throws Exception {
        WebClient webClient = new WebClient(BrowserVersion.BEST_SUPPORTED);
        HtmlPage page = webClient.getPage("https://www.milanuncios.com/textos-del-anuncio/?demandax=n&c=131&idlocalidad=8&p=almeria&x=27&y=0");
        System.out.println(page.asXml());

        HtmlInput inputZona = (HtmlInput) page.getElementById("marca");
        System.out.println(inputZona.asXml());
    }