Problems of loading http urls in matlab.

1 view (last 30 days)
I can access websites using the matlab web browser.
I can NOT download a url link using 'urlread'.
Is there any other matlab function to download the text of a url link?
Another alternative way is to use wget in matlab. I know how to save the url to a local text file and then read it into matlab, but it's inefficient since I have plenty of urls to read. Is there any way I can assign the wget-downloaded text to a variable in matlab straightforwardly?

Accepted Answer

Geoff Hayes
Geoff Hayes on 11 Aug 2014
Is an error being thrown when you used urlread, or is it just that the output is an empty string? What is the line of code that you are using to access the web content?
I don't have wget but (on my Mac) I use curl and can save the output from the call to a variable as per the system examples
% build the command string
cmd = ['curl ' 'http://www.mathworks.com/matlabcentral/answers'];
% execute the command
[status,cmdout] = system(cmd);
% what is the output?
cmdout
Try the above and see what happens!
  4 Comments
Geoff Hayes
Geoff Hayes on 11 Aug 2014
Edited: Geoff Hayes on 11 Aug 2014
I don't see that line when I run the equivalent. (I'm using MATLAB 2014a.)
Interesting that urlread('http://www.google.com','timeout',5) times out, but web('http://www.google.com') works fine (that is what you meant by MATLAB web browser?). Do you need to specify proxy server settings to connect to the internet (due to firewall perhaps)?
Ray Lee
Ray Lee on 11 Aug 2014
Edited: Ray Lee on 11 Aug 2014
Yes, you are all correct.
Now all problems are fixed. Thx a lot.

Sign in to comment.

More Answers (0)

Categories

Find more on Downloads in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!