0

I am trying to get the source HTML code from the latest posts but...

This URL:

http://www.sportsbookreview.com/forum/search.php?do=getnew

Redirect me to:

http://www.sportsbookreview.com/forum/search.php?searchid=26505884

Where I can find the latest posts

How can I get the final URL with cURL?

If I use:

curl -s http://www.sportsbookreview.com/forum/search.php?do=getnew > $shDir$urlLatestPosts

Then it will get other page than what I am looking for, so is there anyway to get that final URL?

1

Use curl -L. From the manual:

   -L, --location
          (HTTP/HTTPS)  If  the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option
          will make curl redo the request on the new place. If used together with -i, --include or -I, --head, headers from all requested pages will be shown.  When  authentica-
          tion  is  used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it won't be able to intercept the user+password. See
          also --location-trusted on how to change this. You can limit the amount of redirects to follow by using the --max-redirs option.

          When curl follows a redirect and the request is not a plain GET (for example POST or PUT), it will do the following request with a GET if the HTTP  response  was  301,
          302, or 303. If the response code was any other 3xx code, curl will re-send the following request using the same unmodified method.
  • I tried it before asking, not work.. – Martini002 Apr 6 '17 at 17:06
  • Could you be more specific than 'not work'? – DopeGhoti Apr 6 '17 at 18:29

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.