无法使用Jsoup.connect获取完整的html

时间:2017-03-31 10:03:49

标签: parsing google-app-engine youtube jsoup meta-tags

我已经实现了显示网址预览的功能,我需要网址的元信息。我使用JSOUP来读取HTML元信息。突然之间,我遇到了youtube url的问题。例如: https://www.youtube.com/watch?v=qszGzNoopTc。当我试图拉出上述网址的元信息时。我将 head tag 视为空。

以下是获取网址html的示例。enter image description here

Document doc = Jsoup.connect((String)url)
            .header("Accept-Encoding", "gzip, deflate")
            .userAgent("Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36")
            .maxBodySize(0)
            .timeout(600000)
            .ignoreContentType(true).get();

注意:我在JAVA& amp; App引擎环境。几天前它工作正常,不确定现在是什么导致了这个问题。

当我在https://try.jsoup.org/尝试时,这很好。

0 个答案:

没有答案