Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中使用jsoup抓取初学者_Android_Web Scraping_Jsoup - Fatal编程技术网

在Android中使用jsoup抓取初学者

在Android中使用jsoup抓取初学者,android,web-scraping,jsoup,Android,Web Scraping,Jsoup,我是一个新手,正试图用Jsoup在Android上废弃一些网站。HTML元素的结构如下所示: <div id="latest-article"> <article> <div class="post-text"> <h3 class="title"> <a href="links">article_title</a>

我是一个新手,正试图用Jsoup在Android上废弃一些网站。HTML元素的结构如下所示:

<div id="latest-article">
    <article>
         <div class="post-text">
              <h3 class="title">
                  <a href="links">article_title</a>
              </h3>
         </div>
    </article>
    <article>
    ...
    </article>
    <article>
    ...
    </article>
</div>

提前谢谢。

为我的小小努力感到抱歉:

Element latestArticle = doc.select("div#latest-article").first();
Elements articles = latestArticle.select("article");
for (Element article : articles) {
    // get the value from href attribute
    Element link = article.select("div.post-text > h3.title > a").first();
    String linkHref = link.attr("href");
    String linkText = link.text();

    System.out.println(linkText + " - " + linkHref);
}
Element latestArticle = doc.select("div#latest-article").first();
Elements articles = latestArticle.select("article");
for (Element article : articles) {
    // get the value from href attribute
    Element link = article.select("div.post-text > h3.title > a").first();
    String linkHref = link.attr("href");
    String linkText = link.text();

    System.out.println(linkText + " - " + linkHref);
}