How to download hotlink protected images? [closed]
Asked Answered
M

4

16

I want to download images from other websites that are hotlink protected. I don't want to link those images to my website. I just wanted to download them.

Mucus answered 6/1, 2010 at 5:14 Comment(3)
With Java? Just do the normal url.openConnection dance. As long as you don't pass in a Referer header, you should get the image.Gambier
(To clarify, most hotlink protection allows connections with no Referer at all, since they are optional in HTTP and may well not be present; they only block present Referer​s pointing to a third-party site. There are some blockers that require the first-party site to be present in the Referer (in which case you'd have to add it manually), but since this has many undesirable side-effects for the site it should be quite rare.)Gambier
Can someone reopen the question so I can answer it?Moseley
G
17

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.

Geminian answered 6/1, 2010 at 5:21 Comment(0)
D
11

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
Dogfight answered 6/1, 2010 at 5:36 Comment(0)
G
5

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);
Geriatrics answered 7/6, 2012 at 14:24 Comment(0)
E
0

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.

Elliott answered 12/12, 2012 at 22:38 Comment(1)
I used the following Postman extension, put the image URL in and only works when hotlinking is not enabled. Are there kinds of hotlinking that disable this? chrome.google.com/webstore/detail/postman/…Moseley

© 2022 - 2024 — McMap. All rights reserved.