0

How do I download and save the particular image from the following web page using wget.

http://www-nass.nhtsa.dot.gov/nass/cds/GetBinary.aspx?SceneView&ImageID=509617654

I tried this

 "C:\Program Files (x86)\GnuWin32\bin\wget" -r -P "C:\temp\" -A jpeg,jpg,bmp,gif,png "http://www-nass.nhtsa.dot.gov/nass/cds/GetBinary.aspx?SceneView&ImageID=509617654"

But the image did not download and save. I am using Windows 7. I guess I am not getting the image since the web page is not a proper html page (no html or asp etc extension). Am I correct?

Community
  • 1
  • 1
Stat-R
  • 5,040
  • 8
  • 42
  • 68

1 Answers1

0

Not exactly. A file extension is not required for URLs containing HTML (e.g. http://google.com/).

By inspecting the HTML source (ignoring that the page has invalid HTML (<script> tag in between <head> and <body>)), we can see it's using JavaScript to alter the image's src attribute on page load (why, who knows...) to /GetBinary.aspx?Scene&ImageID=509617654&CaseID=&Version= (relative to the HTML page).

As wget can't execute JS, this will never work (like this).

However the actual image URL does return a JPEG image, but you'll have to rename it, as, also, the web server (IIS) is misconfigured, as for that URL it returns a header:

Content-Type: E:\Sites\NASS\CDS\/img/jpg

which is invalid, and causes file association problems when downloading in most browsers / clients.

To prove it's there, you can try downloading it directly with wget:

wget "http://www-nass.nhtsa.dot.gov/nass/cds/GetBinary.aspx/GetBinary.aspx?Scene&ImageID=509617654&CaseID=&Version=" -O image.jpg
declension
  • 4,110
  • 22
  • 25