我有这个HTML:
<div class="responsive_friendblocks">
<div class="friendBlock persona offline" href="http://steamcommunity.com/profiles/76561198312248750" data-miniprofile="351983022">
<div class="manage_friend_checkbox" style="display: none;">
<input class="friendCheckbox" type="checkbox" id="friendbox_[U:1:351983022]" name="friends[76561198312248750]" data-steamid="76561198312248750" value="1">
</div>
我想使用Jsoup获取“data-steamid”。我不知道怎么去那里。该代码适用于“data-miniprofile”。它只是没有为“data-steamid”返回任何内容。
这是我的Android代码:
protected Void doInBackground(Void... params) {
try {
// Connect to website
Document document = Jsoup.connect(URL).get();
Elements MiniProfile = document.select("div.friendBlock.persona.offline");
Elements IDs = document.select("input.friendCheckbox");
//Attribute
PlayerMiniProfile = MiniProfile.attr("data-miniprofile");
PlayerID = IDs.attr("data-steamid");
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
}
return null;
}