Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 2747  / 1 Year ago, tue, january 17, 2023, 3:01:33

Possible Duplicate:

wget downloads corrupt JPEG file




I'm trying to do a script so I can set this image as background and update it each 10 minutes, but I cannot even download the image:


$ wget "http://static.die.net/earth/mercator/1600.jpg" -O imagen.jpg


--2012-08-23 17:51:41-- http://static.die.net/earth/mercator/1600.jpg
Solving static.die.net (static.die.net)... 209.151.236.22, 2607:f820:42::16
Connecting with static.die.net (static.die.net)[209.151.236.22]:80... connected.
HTTP Request sent, waiting reply... 200 OK
Length: 37 [image/gif]
Saving to: “imagen.jpg”

100%[======================================>] 37 --.-K/s en 0s

2012-08-23 17:51:42 (5,58 MB/s) - “imagen.jpg” saved [37/37]

And imagen.jpg's size is 37 bytes...


Any idea?


NB: Output of wget was in Spanish, so I translated into English.


More From » scripts

 Answers
3

It looks like it's silently redirecting you to a gif image which just happens to be empty. This is a simple tactic that CDNs use to stop people scraping with tools like wget.



Unfortunately (for them) wget allows you to spoof another user agent string like so:



wget -U 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1' http://static.die.net/earth/mercator/1600.jpg


But you should probably interpret their empty image response as a "please don't use wget on our servers". It's probably in their terms of service.


[#35990] Thursday, January 19, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pipeag

Total Points: 489
Total Questions: 107
Total Answers: 115

Location: Iraq
Member since Fri, Jun 5, 2020
4 Years ago
;