Weboptions: Timeout don't work
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Isabel She
am 16 Jul. 2019
After set options.Timeout = Inf, you just need to add options in the webread syntax, like this:
html = webread(url,'term',searchTerm,options)
Antworten (1)
Ankita Nargundkar
am 20 Okt. 2016
Bearbeitet: Ankita Nargundkar
am 20 Okt. 2016
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 Kommentare
Siehe auch
Kategorien
Mehr zu Web Services finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!