档案交换一周

我们最好的用户提交

可用

肖恩本周的选择是isnetavl经过Rik Wisselink

我最近写一个函数,下载data from a public location online. I had to call it multiple times to get
data for different time ranges but wanted to safe guard against there being no internet connection. If the system failed
要下载数据,我希望能够将Internet连接信息添加到例外

Rik’sisnetavl功能,这是对另一个版本没有Unix支持,这是这样金宝app做的。

这大致是我最终结果的代码。为了运行此操作,我的计算机处于飞机模式。

try百分比循环超过日期,每次存储输出。为了ii = numel(日期):-1:1 data {ii} = string(webread(url,,'日期',日期(ii)));结尾抓住ME%添加有关特定查询的信息。failedquery = MException('DataReader:FailedQuery',,,,'url:%s \ ndate:%s',url,char(日期(ii)));me = me.addcause(failedquery);%如果互联网不可用,请在之前添加更多信息百分比缩减例外。如果〜isnetavl nointernet = mexception('System:NoInternetConnection',,,,'The system is not connected to the internet.');me = me.Addcause(Nointernet);结尾%rethrow有其他原因的例外rethrow(我)结尾
无法确定“ www.tatmou.com”的IP地址使用Webreard(第122行)。mainisnetavl(第28行)数据{ii} = string(webread(url,'date',date',date(ii)))中的错误。引起的:url:https://www.tatmou.com日期:04-JUL-2017 13:00:00系统未连接到Internet

警告:尽管此功能告诉您计算机的互联网连接,但它可能无法反映
MATLAB。Matlab可能有自己的代理设置that interfere with its access to the internet.

Comments

Is connectivity of MATLAB to the internet something you would like to have built-in, perhaps as part of theHTTP接口? If so, please provide your use casehere

Give it a try and let us know what you thinkhere或留下一个评论对于里克。

与Matlab®R2018A一起出版

|
  • 打印
  • 发送电子邮件

Comments

要发表评论,请单击here登录您的数学帐户或创建一个新帐户。