我正在尝试从 html 解析视频 url。我正在使用 Jsoup 解析来解析它。我要解析
<meta property="og:video" content="http://video.foxnews.com/assets/video-player.swf?video_id=2475698001001&d=video.foxnews.com&auto_play=true">
从这个 html。我如何从上面的行中获取此内容。
现在我的代码是:
try {
Connection.Response response = Jsoup
.connect(htmlUrl)
.userAgent(
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21")
.timeout(10000).execute();
int statusCode = response.statusCode();
Log.d("TAG", " status code is: " + statusCode);
if (statusCode == 200) {
doc = Jsoup.connect(htmlUrl).timeout(1000 * 100).get();
Log.d("TAG","Document is created : " + doc );
Elements element = doc.select("meta");
for (Element urls : element) {
//System.out.println(urls.text());
Log.d("TAG", " url is: " + urls.attr("property") + " " + urls.attr("og:video"));
}
} else {
System.out.println("received error code : " + statusCode);
}
我的代码应该改变什么?
先感谢您!