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.
How to download hotlink protected images? [closed]
Asked Answered
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.
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
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);
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.
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.
url.openConnection
dance. As long as you don't pass in aReferer
header, you should get the image. – GambierReferer
at all, since they are optional in HTTP and may well not be present; they only block presentReferer
s pointing to a third-party site. There are some blockers that require the first-party site to be present in theReferer
(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