【问题标题】:Does inputstream contain data of iframe?输入流是否包含 iframe 的数据?
【发布时间】:2017-10-18 07:05:25
【问题描述】:
URL url = new URL("https://www.cs.tut.fi/~jkorpela/html/iframe-pdf.html");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream in = connection.getInputStream();

调用 getInputStream 时,我将所有字节转换为字符串。但为什么我在 iframe 中看不到任何数据迹象?

我的目标是下载 PDF。

【问题讨论】:

    标签: java url iframe inputstream httpurlconnection


    【解决方案1】:

    如果您请求一个 URL,您将只会获得该文件的内容。 iframe 通常实际上是一个单独的页面,因此您需要单独请求。浏览器通常会透明地完成所有这些操作。

    我建议使用 JSoup 之类的库,其中包含许多解析 HTML 的方法,您需要获取 iframe 的 URL(和 PDF 的 URL)。

    【讨论】:

      猜你喜欢
      • 2017-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多