Android jSoup 帮助
我正在尝试从此网址解析html http:// skyalipi.blogspot.com/2011/04/there-is-no-resistance-without.html 使用 jSoup。我
Document doc = Jsoup.parse("http://skyalipi.blogspot.com/2011/04/there-is-no-resistance-without.html");
Log.d("test", "the elements"+doc);
在日志中使用此代码,得到以下内容
05-26 12:05:05.355: DEBUG/test(696): the elements<html>
05-26 12:05:05.355: DEBUG/test(696): <head></head>
05-26 12:05:05.355: DEBUG/test(696): <body>
05-26 12:05:05.355: DEBUG/test(696): http://skyalipi.blogspot.com/2011/04/there-is-no-resistance-without.html
05-26 12:05:05.355: DEBUG/test(696): </body>
05-26 12:05:05.355: DEBUG/test(696): </html>
“我想获取段落内容”。我不知道我哪里错了。我也参考了以下网址 http://jsoup.org/cookbook/extracting- data/attributes-text-html 请帮忙
I am trying to parse html from this url http://skyalipi.blogspot.com/2011/04/there-is-no-resistance-without.html using jSoup. I am using this code
Document doc = Jsoup.parse("http://skyalipi.blogspot.com/2011/04/there-is-no-resistance-without.html");
Log.d("test", "the elements"+doc);
In the log, I am getting the following
05-26 12:05:05.355: DEBUG/test(696): the elements<html>
05-26 12:05:05.355: DEBUG/test(696): <head></head>
05-26 12:05:05.355: DEBUG/test(696): <body>
05-26 12:05:05.355: DEBUG/test(696): http://skyalipi.blogspot.com/2011/04/there-is-no-resistance-without.html
05-26 12:05:05.355: DEBUG/test(696): </body>
05-26 12:05:05.355: DEBUG/test(696): </html>
I Want to get the paragraph contents. I dont know where I am going wrong. I refered to the following url too http://jsoup.org/cookbook/extracting-data/attributes-text-html Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Jsoup 将您的 URL 视为您要解析的文本,并将其转换为有效的 HTML 以便可以解析。我认为您想要连接到该网站并检索该网址的内容,然后解析结果:
编辑
看看文档 作为示例。您可以执行以下操作:
Jsoup is treating your URL as if it is the text that you want to parse, and is converting it into valid HTML so that it can be parsed. I think you want to connect to the site and retrieve the content at that url, then parse the result:
EDIT
Have a look at the documentation for examples. You can do things like: