0

onlick 関数 (getDetails という名前) の結果を取得し、その結果を操作する必要があります。結果がプレーンテキストであるかどうかは気にしません。

<table id="table-registered" class="table-results">
<thead>
    <tr>
        <th class="col-companyname">Legal/Trading Name</th>
        <th class="col-companytype">Type</th>
        <th class="col-acn">ACN</th>
        <th class="col-abn">ABN</th>
        <th class="col-arbn">ARBN</th>
        <th class="col-state">State</th>
        <th class="col-docimage">Docs</th>
    </tr>
</thead>
<tr id='data_25'>
    <td colspan="7" class="row">
        <table class="table-inner">
            <tr>
                <td class="col-companyname" onclick="getDetails('25', 'ARBN=BN98135544&CompName=A%2EAA+AARON+ACTIVE+PLUMBING+GASFITTING+%26amp%3Bamp%3B+DRAINING+24+HOUR+EME&CompStat=REGD&Type=BUSN&BusIDType=Number&BusID=113963483&=')" style="cursor:pointer;">A.AA AARON ACTIVE PLUMBING GASFITTING &amp; DRAINING 24 HOUR EME</td>
                <td class="col-companytype">Business Name</td>
                <td class="col-acn">&nbsp;</td>
                <td class="col-abn">&nbsp;</td>
                <td class="col-arbn">BN98135544</td>
                <td class="col-state">&nbsp;</td>
                <td class="col-docimage">&nbsp;</td>
            </tr>
            <tr id='row_25' style="display:none;">
                <td colspan="7">
                    <div id=div_25>
                    </div>
                </td>
            </tr>
        </table>
    </td>
</tr>

.........

HtmlUnit でソリューションを試してみましたが、うまくいかないようです。

public static void main(String []args){
        final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_17);
        HtmlPage page = null;
        try {
            webClient.setAjaxController(new NicelyResynchronizingAjaxController());
            webClient.waitForBackgroundJavaScript(10000);
            webClient.waitForBackgroundJavaScriptStartingBefore(10000);
            page = webClient.getPage("http://www.abnsearch.com.au/express/results/asic_list.asp?Name=ACTIVE%20PLUMBING%20PTY%20LTD&SearchOptions=1|ASC|0&SearchCount=5");

            final HtmlTable table = page.getHtmlElementById("table-registered");

            for (final HtmlTableRow row : table.getRows()) {
                System.out.println("Found row");


                String onclickAttr = row.getOnClickAttribute();
                ScriptResult result = page.executeJavaScript(onclickAttr);
                System.out.println(result.getJavaScriptResult());

                for (final HtmlTableCell cell : row.getCells()) {
                    System.out.println("   Found cell: " + cell.asText());
                    String onclickAttr2 = cell.getOnClickAttribute();
                    ScriptResult result2 = page.executeJavaScript(onclickAttr2);
                    System.out.println(result2.getJavaScriptResult());

                }
            }
        } catch (FailingHttpStatusCodeException | IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

私が得るのはnet.sourceforge.htmlunit.corejs.javascript.Undefined@194f2e8だけです

また、各行と列で click() を呼び出してみましたが、どちらも機能しませんでした。

HtmlPage x = (HtmlPage)row.click();
System.out.println("   Object: " + x.getTextContent());

前もって感謝します

4

1 に答える 1