MATLAB: Is a url valid

validityweb

Hello,
I'd like to know if a url is valid or not.
For example :
- http://www.fkhzfziufhzoij.com is not valid
- http://www.mathworks.fr is valid
Do you think it's possible ? thank you

Best Answer

The documentation for urlread indicates that you could use the status output variable to indicate if the operation is successful or not.
For your two examples,
[str,status] = urlread('http://www.fkhzfziufhzoij.com');
returns an empty str and status==0.
Whereas,
[str,status] = urlread('http://www.mathworks.fr');
returns the HTML for the page in str and status==1.