如何使用 Jsoup 从网站获取进度条?
How To Get Progressbar From Website With Jsoup?
我想从网站获取进度条信息到我的 android 应用程序。我该怎么做?
网站上的进度条:
<div class="progress progress-striped active">
<div class="bar" id="prog" style="width: 0%;">
</div>
</div>
如何在我的 Android 应用程序中使用此网站进度条到进度条?
希望对您有所帮助。
//String data = "<div class=\"progress progress-striped active\"> <div class=\"bar\" id=\"prog\" style=\"width: 56%;\"> </div> </div>";
//Document doc = Jsoup.parse(data);
Document doc = Jsoup.connect("url").get();
String styleWidth = doc.select("div.progress.progress-striped.active div.bar").attr("style");
String progressText = styleWidth.substring(styleWidth.indexOf("width: ")+"width: ".length(), styleWidth.indexOf("%;"));
int progress = Integer.parseInt(progressText);
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
progressBar.setProgress(progress);
我想从网站获取进度条信息到我的 android 应用程序。我该怎么做?
网站上的进度条:
<div class="progress progress-striped active">
<div class="bar" id="prog" style="width: 0%;">
</div>
</div>
如何在我的 Android 应用程序中使用此网站进度条到进度条?
希望对您有所帮助。
//String data = "<div class=\"progress progress-striped active\"> <div class=\"bar\" id=\"prog\" style=\"width: 56%;\"> </div> </div>";
//Document doc = Jsoup.parse(data);
Document doc = Jsoup.connect("url").get();
String styleWidth = doc.select("div.progress.progress-striped.active div.bar").attr("style");
String progressText = styleWidth.substring(styleWidth.indexOf("width: ")+"width: ".length(), styleWidth.indexOf("%;"));
int progress = Integer.parseInt(progressText);
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
progressBar.setProgress(progress);