あなたは私がjsoup使用してこれらのメッセージを抽出することができますどのように、アドバイスしてくださいでした:Jsoup(正規表現)
リソース/オーディオ/歌/ 73742facb924e6.mp3
今後は今
グリーングレーです
:このコードから<div class="playlist-item" id="playlist-item-2" data-song-id="8365" onmouseover="javascript: pageUtils.playlistItemSharebar(2);" onclick="jwPlayerUtils.playSong(8365, 2, event); _gaq.push(['_setAccount', 'UA-1091709-7']); _gaq.push(['_trackPageview']);"> <input type="hidden" id="song-path-8365" value="resources/audio/songs/73742facb924e6.mp3" /> <input type="hidden" id="song-mode-8365" value="song" /> <input type="hidden" id="song-name-left-8365" value="Future Is Now" /> <input type="hidden" id="song-name-right-8365" value="Green Grey" /> <input type="hidden" id="song-programName-8365" value="" /> <input type="hidden" id="song-img-8365" value="resources/img/songs/98x74_DIR/8365.jpg?201702161231" />
私はすでにしようとしているものをここで
:
Document document = Jsoup.connect(url).execute().parse();
Elements elements = document.select(".playlist-item");
for (Element element : elements) {
System.out.println("Artist: " + element.select("[id~=^song-name-right-[0-9]+$]").select("[value]"));
System.out.println("Song: " + element.select("[id~=^song-name-left-[0-9]+$]").select("[value]"));;
System.out.println("Link: " + element.select("[id~=^song-path-[0-9]+$]").select("[value]"));
}
しかし、結果は完全な文字列です:
入力タイプ= "隠された" ID = "歌パス-8365" の値= "リソース/オーディオ/ input type = "hidden" id = "song-name-left-8365" value = "未来はある" /> 入力タイプ= "hidden" id = "song-name-right -8365 "value =" Green Grey "/>
これに対処するための他の(より簡単で正確な)方法があると確信しています。任意のヘルプ
何を抽出しますか? – thanga
@RamanSahasi、これは正規表現です: "[id - = ^曲名 - 右 - [0-9] + $]" –
@thanga、 "リソース/オーディオ/曲/ 73742facb924e6.mp3、Future Isさて、グリーングレー "私はマッサージでそれを書いた。私は必要なものと必要な場所から書きました。 –