使用Matlab和urlread从https读取数据?

时间:2012-11-22 21:26:23

标签: matlab https urlread

我正在尝试使用网址下载https页面:

STR = urlread( 'https://funds.barclaysstockbrokers.co.uk/clients/bsl/search_factsheet_summary.aspx?code=B0XWN14')

不幸的是,我收到了一个错误:

Error downloading URL. Your network connection may be down or your proxy settings improperly configured.

我尝试使用urlread2(http://www.mathworks.co.uk/matlabcentral/fileexchange/35693-urlread2/content/urlread2.m)

但这给了我这个错误:

Response stream is undefined
 below is a Java Error dump (truncated):
??? Error using ==> urlread2 at 217
Java exception occurred:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

我需要做什么?

3 个答案:

答案 0 :(得分:1)

这就是我的所作所为:

http://www.mathworks.com/matlabcentral/answers/39563-managing-public-key-certificates-in-matlab

简要总结: 它涉及使用Chrome导出证书,然后使用http://portecle.sourceforge.net/将证书添加到Matlab的Java的cacerts文件中

答案 1 :(得分:0)

这是证书安全信任问题。

我在Mathematica中尝试了相同的命令,并且看到了这个漂亮的弹出窗口,询问我是否要接受证书

str="https://funds.barclaysstockbrokers.co.uk/clients/bsl/search_factsheet_summary.aspx"
Import[str]

enter image description here

当我单击“仅接受此会话”时,我获得了数据确定

我不使用urlread()。但至少现在你知道为什么了。我没有在urlread中看到选项 做上面的事情。您可能需要在Matlab中使用另一个API来执行您想要的操作。可能是matlab文件交换的东西可能会处理这个。

答案 2 :(得分:0)

在matlab 2014b之后,你可以使用:

DATA = webread(URL)

此新API没有urlread命令所具有的所有问题。