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.

Amit
  • 33,847
  • 91
  • 226
  • 299
  • 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. – bobince Jan 06 '10 at 05:21
  • 1
    (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.) – bobince Jan 06 '10 at 05:36
  • Can someone reopen the question so I can answer it? – Fering Nov 24 '18 at 16:11

4 Answers4

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.

Aziz
  • 20,065
  • 8
  • 63
  • 69
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
Gattster
  • 4,613
  • 5
  • 27
  • 39
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);
Birdman
  • 5,244
  • 11
  • 44
  • 65
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.

Dan Ross
  • 3,596
  • 4
  • 31
  • 60
  • 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? https://chrome.google.com/webstore/detail/postman/menjpgnehajklienmnkhflpmkncmnfno/related – Fering Nov 24 '18 at 15:03