Android的JSoup例 [英] Android JSoup Example

查看:150
本文介绍了Android的JSoup例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道有没有人得到了一个样本Eclipse项目JSoup的工作实现?我试着用它来从网站上提取信息,并已经遍布谷歌试图让它工作,但不能。如果有人可以帮助我真的AP preciate吧。

I was just wondering has anyone got a sample eclipse project with a working implementation of JSoup? Im trying to use it to pull information from websites and have gone all over google trying to get it to work but cant. If anyone could help I'd really appreciate it.

推荐答案

JSoup是很容易使用,看看从JSoup食谱这些exemples:

JSoup is really easy to use, look at these exemples from the JSoup cookbook:

首先,你要连接到的网页要使用解析:

First, You have to connect to the webpage you want to parse using:

Document doc = Jsoup.connect("http://example.com/").get();

然后,您可以选择使用 JSoup选择语法的页面元素。

例如,假设你要选择的 DIV 标签与 ID 属性设置为全部内容测试,你只需要使用:

For instance, say you want to select all the content of the div tags with the id attribute set to test, you just have to use:

元素的div = doc.select(#DIV测试);

要获取申报单,那么你就可以对它们使用迭代:

to retrieve the divs, then you can iterate on them using:

for (Element div : divs)
    System.out.println(div.text());
}

这篇关于Android的JSoup例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆