11

I am trying to download a URL that is like http://www.somesite.com/restaurants.html#photo=22x00085.

I put it in between single quotes, but it only downloads http://www.somesite.com/restaurants.html which is not the correct page.

Is there a solution?

  • can't test this now, but from what I remember %20 works for space, so %23 would probably work for # (%23 is the percent-encoding for #) – lupincho Oct 13 '12 at 16:03
  • 3
    isn't it the same HTML file? The # might just tell the web browser to jump to a particular part of the page. – barlop Oct 13 '12 at 17:25
20

wget is working fine. The URI syntax specifies that the fragment – the #foo part – is to be interpreted entirely client-side, and not used when retrieving the document itself.

For example, if it's a HTML page, the browser might scroll down to a named section, or – in your case – trigger some JavaScript code that shows a particular photo.

In other words, as far as wget is concerned, the URIs

  • http://www.somesite.com/restaurants.html#photo=22x00085 and
  • http://www.somesite.com/restaurants.html

...point to the same page /restaurants.html. It's up to your browser to do the rest. Opening restaurants.html#photo=22x00085 in the browser should work fine.

8

Without visiting the proper link, I can't tell which one it is, but there are only two options:

  • I've seen many sites that abuse the URL fragment in this way; at the top of the list is Google themselves. This violates a whole bunch of RFCs, but not that many people seem to care, since "it works"... – Michael Hampton Oct 13 '12 at 21:01
  • 1
    @MichaelHampton: Could you point out exactly which RFCs it violates? – user1686 Oct 15 '12 at 16:48
  • @grawity RFC 2396, part 2.4.3 can be read to say # is not part of any URI. This seems to be relaxed in RFC 3986, being vague enough not to define anything. – Rich Homolka Oct 17 '12 at 15:15
  • 1
    @RichHomolka: It only says that "foo#bar" is actually called an "URI-Reference", consisting of the URI (used for data retrieval) and the fragment (interpretation left to the user-agent). It would be violated only if the fragment was actually sent in a HTTP request. – user1686 Oct 17 '12 at 15:34
0

That's not the URL for the image. It's the URL for a page that uses a script or other code to fetch the image. Try loading the page with JavaScript turned off. That's what wget is fetching for you.

To find the URL for the image, try visiting the page through your browser and then right-clicking on the photo. There should be an option to view information about the image, including its URL.

If that doesn't work, it may be because the image is being loaded through Flash or some other client-side program. You can use Fiddler or Wireshark to watch what URL its loading.

If you give us the actual URL of the site with the image, we can help you determine how the image is being loaded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.