I have tried to download a file using curl "https://www.dropbox.com/s/tf7e7vndqd9hv05/Ace_The_IELTS.pdf?dl=0" -o "file.pdf"
but it downloads a file which is of few bytes. When I open the link in the browser I see the web page opened with the pdf but not downloaded to my desktop. I guess that curl command is downloading the webpage but not exact pdf file. Can anyone please help me in downloading the file using curl. Am I missing anything? Thanks
Add a comment
|
1 Answer
Dropbox file links go to a webpage, that then redirects to the actual content.
The link to the above PDF is actually at
https://dl.dropboxusercontent.com/content_link/v0qPqJrCIS7IvTmXr0pXBFKnnbmZpsRfSNxDhfqcjLg88F7ErNCyNAaOIATPKrWT?dl=1
The easiest way I can think to determine the actual url is to first do:
curl "https://www.dropbox.com/s/tf7e7vndqd9hv05/Ace_The_IELTS.pdf?dl=1" -o "temp.txt"
(note the dl=1
)
Then look at the temp.txt
:
<html>
<head><title>Found</title></head>
<body>
<h1>Found</h1>
<p>The resource was found at <a href="https://dl.dropboxusercontent.com/content_link/jGdZ7mfVMNV7VCiauE9T7kGpaOyBKyu6i8KaAzqLzUSaEd2ElXllzDeQEC8DCxHr?dl=1">https://dl.dropboxusercontent.com/content_link/jGdZ7mfVMNV7VCiauE9T7kGpaOyBKyu6i8KaAzqLzUSaEd2ElXllzDeQEC8DCxHr?dl=1</a>;
you should be redirected automatically.
<!-- --></p>
<hr noshade>
<div align="right">WSGI Server</div>
</body>
</html>
Then you'll see the correct url.