0

我正在尝试解析一个视频资源cinemaonline.kg 以获取视频文件的链接。起初我试图将打开的页面保存在记事本中。我看了看,发现:

[a id="onlineplayer" onmouseover="jQuery('a#onlineplayer').fancybox({'width' : '8', 'height' : 430, 'autoScale' : true, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe' , 'closeClick' : 'false' , 'hideOnOverlayClick':false, 'hideOnContentClick':false});" onclick="window.ui.hitMovie(74);window.ui.setFileDownloaded(74);" class="minibutton" href="http://cinemaonline.kg/pl.php?player=ftp&uid=1953&movieid=74&fileid=74&v=6b576ed87c32f85f9252e80591ca1228">[span]Смотреть[/span][/a]

<> - 此字符已更改为此字符 - [],因为它们未显示。

所以我试图用jsoup抓住它。但它返回了我的空指针异常。我查看了页面的返回字符串,没有标签 [a id = "onlineplayer" ...]。我想,也许页面总是由一个脚本生成:

[a id=\"onlineplayer\" onmouseover=\"jQuery(\'a#onlineplayer\').fancybox({\'width\' : \'8\', \'height\' : 430, \'autoScale\' : true, \'transitionIn\' : \'none\', \'transitionOut\' : \'none\', \'type\' : \'iframe\' , \'closeClick\' : \'false\' , \'hideOnOverlayClick\':false, \'hideOnContentClick\':false});\" onclick=\"window.ui.hitMovie(${movie.movie_id});window.ui.setFileDownloaded(${file.file_id});\" class=\"minibutton\" href=\"${file.links.license|escape}\"][span]Смотреть[/span][/a]

比我尝试用 HtmlUnit 解析它:

String url = "http://cinemaonline.kg/#/movie/id/74";
WebClient webClient = new WebClient();
webClient.setJavaScriptEnabled(true);
HtmlPage page = null;
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setThrowExceptionOnScriptError(false);
try {
    page = webClient.getPage(url);
} catch (FailingHttpStatusCodeException e1) {
    e1.printStackTrace();
} catch (MalformedURLException e1) {
    e1.printStackTrace();
} catch (IOException e1) {
    e1.printStackTrace();
}
webClient.waitForBackgroundJavaScript(10000);
webClient.closeAllWindows();
System.out.println(page.asXml());

但它返回给我的文本与 jsoup 返回的文本相同。我知道该页面使用 javascript 和 ajax(?),但我真的不知道它是如何工作的。如何返回生成的文本?请帮忙

4

1 回答 1

0

检查此问题以获取图像链接Jsoup:如何获取图像的绝对 url?

同样,您可以获取视频元素并在其上使用 yourvideoelement.attr("href") 来获取返回的链接

于 2013-02-23T06:37:28.177 回答