如何使用htmlunit解析跨度中的按钮?

时间:2016-06-08 03:33:16

标签: html htmlunit

我想使用htmlunit解析下一页按钮以实现

nextPage = anchor.click();

但是,锚列表不包括范围内的下一页按钮。我该怎么办?

List<HtmlAnchor> profileDivLinks  = (List<HtmlAnchor>) currentPage.getByXPath("//div[@class='turn_page']//a");

Html代码:

<div class="turn_page">
<div class="turn_page_num" style="text-align: center;">
<p id="smart-paginator">
<span href="#" class="sp_pre"/>
<span class="sp_a">
<a href="#">1</a>
<a class="point" href="javascript:void(0)">...</a>   
<a class="on">9</a>
<a href="#">10</a>
<a href="#">11</a>
<a href="#">12</a>
<a href="#">13</a>
<a class="point" href="javascript:void(0)">...</a>
<a class="a_num_last" href="#">552</a>
</span>
<span href="#" class="sp_next"/>
</p>
<script type="text/javascript">   
$("#pagetor").pagination(16, {
                        items_per_page:50,
                        num_edge_entries:1,
                        prev_text:"&nbsp;",
                        next_text:"&nbsp;",
                        prev_show_always:false,
                        next_show_always:false,
                        current_page:(9-1),
                        callback:function(page){
                          var queryString="st=1&sxrlx=&sxrmc=&ah=&sxfj=&page="+(page+1);
                          queryString=encodeURI(encodeURI(queryString));
                                    var url="index.htm?"+queryString;
                          window.location.replace(url);
                        }
                      });
</script>
</div>
</div>
</div>

0 个答案:

没有答案