Using wget to download image from url pointing to jpg - http

I have a link pointing to a .jpg: https://images.wallpapersden.com/image/download/nature-sunset-simple-minimal-illustration_am1ramqUmZqaraWkpJRnamtlrWZpaWU.jpg
I'm trying to download it using wget https://images.wallpapersden.com/image/download/nature-sunset-simple-minimal-illustration_am1ramqUmZqaraWkpJRnamtlrWZpaWU.jpg
I am getting:
Connecting to images.wallpapersden.com (images.wallpapersden.com)|104.26.8.233|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2021-12-22 05:24:31 ERROR 403: Forbidden.
I'm assuming I'm not using wget correctly, or need to use some other cli tool?
--Update--
I've just learned that I can use curl to download the image e.g curl url/to/image.jpg > saveas.jpg, but I'm still curious if there's anyway to do this with wget?

I've just learned that I can use curl to download the image e.g
curl url/to/image.jpg > saveas.jpg, but I'm still curious if there's
anyway to do this with wget?
I run few test regarding https://images.wallpapersden.com/image/download/nature-sunset-simple-minimal-illustration_am1ramqUmZqaraWkpJRnamtlrWZpaWU.jpg and it seems to blacklist wget. When making HTTP request User-Agent header is used to inform what tool made said request.
wget has --user-agent which allow supplying User-Agent, so wget appear as something else to server, for example to impostor Firefox version 47 do
wget --user-agent="Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0" https://images.wallpapersden.com/image/download/nature-sunset-simple-minimal-illustration_am1ramqUmZqaraWkpJRnamtlrWZpaWU.jpg
wget's man page gives following rationale for this ability
The HTTP protocol allows the clients to identify themselves
using a "User-Agent" header field. This enables
distinguishing the WWW software, usually for statistical
purposes or for tracing of protocol violations. Wget
normally identifies as Wget/version, version being the
current version number of Wget.
However, some sites have been known to impose the policy of
tailoring the output according to the "User-Agent"-supplied
information. While this is not such a bad idea in theory, it
has been abused by servers denying information to clients
other than (historically) Netscape or, more frequently,
Microsoft Internet Explorer. This option allows you to
change the "User-Agent" line issued by Wget. Use of this
option is discouraged, unless you really know what you are
doing.
Specifying empty user agent with --user-agent="" instructs
Wget not to send the "User-Agent" header in HTTP requests.

Related

HTTP header to force HTTP/1.1 when using HTTPS

I cannot find this information anywhere, since all questions are library specific or are about forcing use of HTTP/2.
Is it possible to set (force) the HTTP version to HTTP/1.1 via headers when connecting to a server using HTTPS?
I have read that servers set the HTTP version to HTTP/2 by default when using HTTPS, but that HTTPS does not necessarily depend on HTTP/2.
I ask because I am connecting to an end server that uses HTTPS but the server only supports HTTP/1.1 (possibly connecting via an intermediary server that supports HTTP/2).
I know you can force curl to use HTTP1.1 using a flag but I am not sure if curl sets something in the headers or does something at a lower level.
--http1.1
I can access the end server successfully using curl when using the --http1.1 flag. Without the flag, the request fails.
Ideally, I want to use other solutions other than curl to connect to the end server.

combining websockets and http

I'm creating a program that wants to show statistics.
For that I decided to use websockets and http. Websockets because it requires no polling but allows my server to push any changes (I'm open for suggestions for different solutions) so quick updates. For websockets I use the websocket++ library and for http I use libmicrohttpd.
The program runs on Unix/Linux systems.
Now using websocket++ creating the websockets is simple. I let the user decide on a portnumber and that's that. Same thing for http using libmicrohttpd.
The problem now is, how can I point from html to that websocket service?
I only know a portnumber (that listens on all network interfaces; it binds to 0.0.0.0) and not a hostname. I tried http://:8001/ (so without any hostname, or ip address) but at least firefox doesn't take that.
So how can I resolve that?
I could in theory let websocket++ do the http handling but that doesn't work for binary files like images and it also does not let you process HEAD-requests.
I only know a portnumber (that listens on all network interfaces; it binds to 0.0.0.0) and not a hostname. I tried http://:8001/ (so without any hostname, or ip address) but at least firefox doesn't take that.
Thats not possible to let a webbrowser search for a specified webpage at a specified port, because you have more than million webserver addresses (you cannot not know at all) to search for a open port.
So the only very solution would be to provide an url in the html you mentioned above a script can use to connect to your service.
If you want to bind to localhost (127.0.0.1): http://localhost:8001/ or http://127.0.0.1:8001/
Found the solution:
An http-request has (usually - tried with chrome & firefox) an "Host:"-header. E.g.:
GET / HTTP/1.1
Host: keetweej.vanheusden.com:8000
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
So what I do now is cut the hostname from the Host-record and add the portnumber of the websockets to it.
This works!

Wget 503 unavailable error

$ wget www.amazon.com
Resolving www.amazon.com... 205.251.242.54
Connecting to www.amazon.com|205.251.242.54|:80... connected.
HTTP request sent, awaiting response... 503 Service Unavailable
2015-10-12 23:27:24 ERROR 503: Service Unavailable.
I am trying to issue wget on a URL and getting this error. I need to store the HTML files and I was hoping wget would work :(
I tried using the --no-proxy option but it doesn't help.
The problem is that amazon firewall is blocking connections whose user-agent is not set, or incorrect.
You may try setting user agent to wget and get amazon with following command (note that you may need to change a valid user agent if this one becomes invalid):
wget -U "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36" https://amazon.com
I can issue wget http://www.amazon.com without any problem.
My guess is that you got blocked by amazon after scrapping a little bit to much...
503 Service Unavailable
The server is currently unable to handle the request due to a
temporary overloading or maintenance of the server. The implication is
that this is a temporary condition which will be alleviated after some
delay. If known, the length of the delay MAY be indicated in a
Retry-After header. If no Retry-After is given, the client SHOULD
handle the response as it would for a 500 response.
Note: The existence of the 503 status code does not imply that a
server must use it when becoming overloaded. Some servers may wish
to simply refuse the connection.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

HTTP Version problem POSTing XML messages to a server

I have a DLL library, which I have no control over, that builds a XML message and sends it over HTTP to a web server. Due to the strict specifications, the server will only accept message with POST HTTP/1.1. However, the logs in the server shows receiving messages being POSTed HTTP/1.0. If I open the URL directly into a browser, the log shows GET HTTP/1.1, which is correct. We're not going through a proxy and the gateway isn't changing the version from what I can tell. I've tried on two different networks and I get the same error. Also, I have tried on Windows Server 2003 and Windows XP Pro, both of which should support HTTP 1.1.
Does anyone have any ideas why the server is receiving HTTP/1.0 using a POST, but using a GET shows HTTP/1.1?
Edit:
I've contacted the DLL maker about this, but their help isn't that great.
Edit 2:
Using Fiddler, I was able to extract the header, which is posted below. As you can see it's using HTTP/1.0.
POST /48A548C0BA8211DEA1EEE5AF2B3D5823;48A548C1BA8211DEA1EE8EF735B81699/
SJzWLaVEESCESCX6ESCESCW~ESC6FESCwxEuESCESCAb,L7ESCecvESCuESCESCrBESCHpESC3
ESCESCJw_ESCESClrj,ESC_4xESCOQpLwyRJGgp6p3YDG!uvXESCESC6!wVxESC7.dESCcTvmG5WM HTTP/1.0
Content-Type: application/xml;charset="utf-8"
Host: ***
Content-Length: 787
Sounds like you're out of luck seeing as you can't change the DLL. According to your response above in the comments, it seems like the DLL you're using is using HTTP/1.0 to send the HTTP requests to the server.
This is as good an answer as I can provide you with, given that you did not specify which DLL you are talking about or provided additional details.
I would suggest you to take a closer look at the DLL you're using to see if it is possible to instruct that library to use HTTP/1.1 for the requests it's sending out.
Good luck.
Write a server that acts a proxy, accepts http/1.0 obviousy, and then forwards to the destination server. This could work if you only have destination server. Otherwise get in touch with the vendor...... or perhaps take up reverse engineering as a side hobby.
Also on fiddler you should see the request and and response. You can correctly configure fiddler2 with any httpclient (besides just IE) using this reference: http://www.fiddler2.com/fiddler/help/hookup.asp

Why can't I connect with a non-browser application to this url?

Anyone knows why this url rejects connection requests being sent by a non-browser application (wget,curl, elinks!): http://sube.garanti.com.tr
https://sube.garanti.com.tr/isube/login/en
It's my bank account and I'm trying to make my transfers with a script but as you see this super secured servers do not allow me.
Any suggestions?
Azer
Try this:
wget --referer="http://www.google.com" --user-agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" --header="Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" --header="Accept-Language: en-us,en;q=0.5" --header="Accept-Encoding: gzip,deflate" --header="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" --header="Keep-Alive: 300"
This may trick the site into thinking you have a "legitimate" browser
Well, I've tried doing this:
wget http://sube.garanti.com.tr
which timed-out.
but doing this:
wget https://sube.garanti.com.tr/isube/login/en
gave me website's source. It is frames base and I'm getting the frames definitions.
The reason for that is probably, that the site is inaccesible through normal (http) connection, you have to use secured one (https).
However, as a rule of thumb, I'd try to set User-Agent: header for any such application, as noted by pjc50.
Maybe it's because you need to login before doing anything at this url?
You can login into sites by using perl's LWP, for example, by submitting login forms properly.
P.S. I can't connect to sube.garanti.com.tr with my browser either.
AFAIK wgte, curl opens the site in the server side. So check for your firwall (if any) and see if it is blocked.
Also the site can also be blocking incoming requests. Its a banking site and we can expect some security restrictions.
Some websites check the User-Agent: header. You might have to configure your downloader to identify itself as "Mozilla" rather than itself.

Resources