Weboptions: Timeout don't work
21 次查看(过去 30 天)
显示 更早的评论
I am using the Example 1 from webread command help.
url = 'http://www.mathworks.com/matlabcentral/fileexchange'
searchTerm = 'sensor-data-acquisition'
html = webread(url,'term',searchTerm)
the webread always gave me error " timed out after 5 seconds. Set options.Timeout to a higher value." So I use the weboptions to specify the Timeout to inf, but webread don't seems to know.
options =
weboptions with properties:
CharacterEncoding: 'auto'
UserAgent: 'MATLAB 9.0.0.341360 (R2016a)'
Timeout: Inf
Username: ''
Password: ''
KeyName: ''
KeyValue: ''
ContentType: 'auto'
ContentReader: []
MediaType: 'application/x-www-form-urlencoded'
RequestMethod: 'auto'
ArrayFormat: 'csv'
html = webread(url,'term',searchTerm)
Error using webread (line 119) The connection to URL 'http://www.mathworks.com/matlabcentral/fileexchange?term=sensor-data-acquisition' timed out after 5 seconds. Set options.Timeout to a higher value.
1 个评论
Isabel She
2019-7-16
After set options.Timeout = Inf, you just need to add options in the webread syntax, like this:
html = webread(url,'term',searchTerm,options)
回答(1 个)
Ankita Nargundkar
2016-10-20
编辑:Ankita Nargundkar
2016-10-20
I see that your Timeout property in weboptions is set is Inf. By default it is 5. You are probably seeing the error because of this. You can reset the Timeout property in the following way from the MATLAB command window
>> options = weboptions
>> options.Timeout = 5
Now execute these lines below in MATLAB command window. You should be able to read data from the url.
>>url = 'http://www.mathworks.com/matlabcentral/fileexchange'
>>searchTerm = 'sensor-data-acquisition'
>>html = webread(url,'term',searchTerm)
I was able to successfully fetch the html data from the url in R2016a
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Web Services 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!