1

jSoupを使用して、このURLhttp : //skyalipi.blogspot.com/2011/04/there-is-no-resistance-without.htmlからhtmlを解析しようとしています。私はこのコードを使用しています

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>

段落の内容を取得したい。どこが間違っているのかわかりません。次のURLも参照しましたhttp://jsoup.org/cookbook/extracting-data/attributes-text-html助けてください

4

1 に答える 1

1

Jsoupは、URLを解析するテキストであるかのように扱い、解析できるように有効なHTMLに変換します。サイトに接続してそのURLのコンテンツを取得し、結果を解析したいと思います。

Document doc = Jsoup.connect("http://skyalipi.blogspot.com/2011/04/there-is-no-resistance-without.html").get();

編集

例については、ドキュメントをご覧ください。次のようなことができます。

Element example = doc.getElementById("alternatives1");
Log.d("test","example "+example.text());
于 2011-05-26T07:11:39.303 に答える