Weboptions: Timeout don't work
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Isabel She
el 16 de Jul. de 2019
After set options.Timeout = Inf, you just need to add options in the webread syntax, like this:
html = webread(url,'term',searchTerm,options)
Respuestas (1)
Ankita Nargundkar
el 20 de Oct. de 2016
Editada: Ankita Nargundkar
el 20 de Oct. de 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 comentarios
Ver también
Categorías
Más información sobre Web Services en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!