下载 Line 图片但未获得许可

问题描述 投票:0回答:1

我正在尝试使用Java来下载这些漫画图片。我从 HTML 代码中获取了这些图片的 URL,但是当我连接到它时,服务器告诉我我没有访问上面图片的权限。 我试图找出是否有一些帖子或获取请求来请求许可,但找不到它。有人可以帮助我了解获得访问权限的想法吗? 非常感谢^^!

页面链接:http://www.webtoons.com/zh-hant/drama/yushentongxing/%E7%AC%AC1%E8%A9%B1-%E7%A5%9E%E7%9A%84 %E5%AF%A9%E5%88%A4-01/观众?title_no=734&episode_no=1

和图片链接:http://webtoon.phinf.naver.net/20160901_41/1472713930299oYcIe_JPEG/147271393026973416.jpg?type=q90

拒绝消息:

推荐被拒绝 您无权访问“http://webtoon.phinf.naver.net/20160901_41/1472713930299oYcIe_JPEG/147271393026973416.jpg?”在此服务器上。 参考#24.5e41ca3.1516454916.3d5b39b

这是我下载图片的代码:

URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
BufferedImage image = ImageIO.read(url);
ImageIO.write(image, "jpg", new File(output));
java url
1个回答
1
投票

服务器只需检查 Referer HTTP 标头以匹配“http://www.webtoons.com/”(从页面加载图像时由浏览器自动添加)

因此通过 API 添加此标头应该足够了,以下代码为我打印 200 个成功代码:

        URL url = new URL("http://webtoon.phinf.naver.net/20160901_41/1472713930299oYcIe_JPEG/147271393026973416.jpg?type=q90");
        HttpURLConnection connection = (HttpURLConnection)url.openConnection();
        connection.setRequestProperty("Referer", "http://www.webtoons.com/");
        int responseCode = connection.getResponseCode();
        System.out.println(responseCode);
© www.soinside.com 2019 - 2024. All rights reserved.