【问题标题】:how to get the pagination url's如何获取分页网址
【发布时间】:2012-02-10 21:15:38
【问题描述】:

我使用 HTTPClient 和 Jsoup 来获取 url 并浏览页面。我有一个场景,单个链接有 3 或 4 个页面,由分页控制。 onSubmit 每个数字,发布操作并更改 url 并完成导航。我怎样才能从主页获得这个网址?

这就是我在 UI 中的分页方式

<div class="pagination">
<div class="label">Page: </div>         
<div class="button selected" onclick="$('.page-position', $(this).closest('form')).attr('value', $(this).html()); $(this).closest('form').submit();">1</div>        
<div class="button " onclick="$('.page-position', $(this).closest('form')).attr('value', $(this).html()); $(this).closest('form').submit();">2</div>
<div class="button " onclick="$('.page-position', $(this).closest('form')).attr('value', $(this).html()); $(this).closest('form').submit();">3</div>            
<div class="button" onclick="$('.page-position', $(this).closest('form')).attr('value', 2);$(this).closest('form').submit();">Next</div>
</div>

【问题讨论】:

  • 我们无法知道您的文档是如何分页的!投反对票。

标签: java httpclient jsoup


【解决方案1】:

Jsoup 解析静态 HTML。 URL 由 Javascript/JQuery 创建。所以你不能用 Jsoup 来做。你可以尝试HtmlUnit创建页面并渲染Javascript,然后选择div很简单。

【讨论】:

    【解决方案2】:

    这取决于您要访问的页面。如今,大多数网站的 url 结构都非常好,因此归结为解释 url 的难易程度。您可以在 firefox 上使用 firebug 来获取 css 路径/xpath 并使用 jsoup http://jsoup.org/cookbook/extracting-data/dom-navigation

    另一方面,如果该站点具有非结构化 url,则只需像使用浏览器一样导航它,即来回浏览。使用带有链接的第一页作为锚点,然后返回和前进。在 Python 上,您可以使用 mechanize 来做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-01
      • 1970-01-01
      • 2017-10-16
      • 2018-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-28
      相关资源
      最近更新 更多