pdf file direct download

Suppose we have a website:
fullstudy.com/mathematics/mathematics-book.pdf
How can we download this pdf file using urlwrite or websave, using matlab?
Directly downloading this file from the web (without using Matlab) is not an option.

Answers (1)

Chunru
Chunru on 29 Nov 2021
Edited: Chunru on 29 Nov 2021
url = "https://www.mathworks.com/help/pdf_doc/matlab/learn_matlab.pdf";
tic
urlwrite (url, 'learn_matlab.pdf');
toc
Elapsed time is 0.315862 seconds.
dir
. .. learn_matlab.pdf

5 Comments

b
b on 29 Nov 2021
This way it takes an enormous amount of time.
Looking for some other way please.
What is the time it takes? See the updated code for time spent.
Let me guess, you're trying to scrape a large number of files from a website. If that's the case you probably should contact the website owner to check if they're okay with you scraping the website (if not they may block you from accessing it, thinking your access to be part of a DDOS attack) and if they have some easy way (like an API) for you to access the set of files you want all at once.
It is only a small number of (100 or so) serialized files.
With the simple urlwrite way, it takes about 5 minutes for a ~20MB pdf file. It is not the issue of their server, because direct download (from web) takes less than 5 seconds for the same file.
Is there any other way to do this which will have a similar timeline (seconds)?
For the serialized version, the exact structure is like this:
fullstudy.com/mathematics_01/mathematics-book_01.pdf
fullstudy.com/mathematics_02/mathematics-book_02.pdf
fullstudy.com/mathematics_04/mathematics-book_04.pdf
and so on, with some entries in between missing.
Why not trying something like FileZilla in this case?

Sign in to comment.

Categories

Asked:

b
b
on 29 Nov 2021

Commented:

on 29 Nov 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!