如何下载受盗链保护的图片?

发布于 2024-08-16 18:53:53 字数 1436 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

无所的.畏惧 2024-08-23 18:53:53

常用的热链接保护方法检查"Referrer" HTTP 标头 与原始网站的域名匹配。

您可以通过手动设置该标头以指向网站中的页面来轻松绕过该问题。

The usual hotlink-protection method checks if the "Referrer" HTTP Header matches the domain name of the original website.

You can easily bypass that by setting that header manually to point to a page in the website.

も让我眼熟你 2024-08-23 18:53:53

您需要传递 Referrer http 标头。您可以在大多数 UNIX 系统上使用 wget 执行此操作,如下所示:

wget --referer=http://www.google.com/ http://www.google.com/intl/en_ALL/images/logo.gif

这是一种原始方法,以便您准确了解发生了什么:

telnet google.com 80
GET /intl/en_ALL/images/logo.gif HTTP/1.1
REFERER: http://www.google.com/
HOST: www.google.com

You need to pass the referrer http header. You can do this with wget on most unix systems as follows:

wget --referer=http://www.google.com/ http://www.google.com/intl/en_ALL/images/logo.gif

Here a raw way to do it so you see exactly what is going on:

telnet google.com 80
GET /intl/en_ALL/images/logo.gif HTTP/1.1
REFERER: http://www.google.com/
HOST: www.google.com
没有你我更好 2024-08-23 18:53:53

您可以使用以下代码下载受热链接保护的图像:

URL url = new URL("http://www.somesite.com/picture.jpg");

URLConnection urlCon = url.openConnection();
urlConn.setRequestProperty("Referer", "http://www.somesite.com");
urlConn.connect();

InputStream urlStream = urlCon.getInputStream();

Image image = ImageIO.read(urlStream);

You can download hotlink protected images by using the following code:

URL url = new URL("http://www.somesite.com/picture.jpg");

URLConnection urlCon = url.openConnection();
urlConn.setRequestProperty("Referer", "http://www.somesite.com");
urlConn.connect();

InputStream urlStream = urlCon.getInputStream();

Image image = ImageIO.read(urlStream);
梦过后 2024-08-23 18:53:53

Chrome 的 Postman 扩展允许您发出自定义 http 请求。我发现了一个被热链接阻止的图像,复制了它的 url 并将其输入到 Postman 中以获取它。

The Postman extension for Chrome lets you make custom http requests. I found a hotlink-blocked image, copied it's url and entered it into Postman to GET it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文