Azzera filtri
Azzera filtri

Weboptions: Timeout don't work

25 visualizzazioni (ultimi 30 giorni)
YW
YW il 10 Ott 2016
Commentato: Isabel She il 16 Lug 2019
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 Commento
Isabel She
Isabel She il 16 Lug 2019
After set options.Timeout = Inf, you just need to add options in the webread syntax, like this:
html = webread(url,'term',searchTerm,options)

Accedi per commentare.

Risposte (1)

Ankita Nargundkar
Ankita Nargundkar il 20 Ott 2016
Modificato: Ankita Nargundkar il 20 Ott 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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by