How Do You Get curl to Work when the Web Page is Working?

Problem scenario
You can download a file with Lynx and wget. But curl is not working. What should you do?

First, try to curl the web page without redirecting the output. If the curl command creates a file, it does not necessarily give you an accurate depiction. You may want to examine the file with a text editor. What you see without redirecting the output to a file (that is allowing the output to echo to the screen) may provide a clue. If the the word "redirect" is displayed (referring to an HTTP), you need the -L flag (with no quotes). This way curl can follow the redirection and obtain the file.

For example, try this command (where is the URL you are trying to download with curl):

curl -L > /tmp/local.html

Leave a comment

Your email address will not be published. Required fields are marked *