webread.m - odd behavior in 2016B.

I am using MATLAB 2016B and win10Pro. I have a webpage which I want to download the data from.
I try
url1 = 'https://openfigi.com/search#!?search=CUSTOM&pageSize=100&page=1&filters=EXCH_CODE:..cme&simpleSearchString=S%26P500%20EMINI%20OPTN';
url2 = 'http://www.bbc.co.uk/news';
data1a = urlread(url1);
data2a = urlread(url2);
Both these functions execute and return ok. However data1a does not contain the data from the tables. So I then try
data1b = webread(url1);
data2b = webread(url2);
For this both calls return
Error using webread (line 116)
Too many input arguments.
35 throwAsCaller(e)
K>> e
e =
MException with properties:
identifier: 'MATLAB:TooManyInputs'
message: 'Too many input arguments.'
cause: {0×1 cell}
stack: [3×1 struct]
K>> e.stack
ans =
3×1 struct array with fields:
file
name
line
K>> e.stack.file
ans =
C:\Program Files\MATLAB\R2016b\toolbox\matlab\external\interfaces\webservices\restful\+matlab\+internal\+webservices\urlencode.m
ans =
C:\Program Files\MATLAB\R2016b\toolbox\matlab\external\interfaces\webservices\restful\private\encodeInputs.m
ans =
C:\Program Files\MATLAB\R2016b\toolbox\matlab\external\interfaces\webservices\restful\webread.m
I then try and drill down into encodeInputs.m which has the full address:
C:\Program Files\MATLAB\R2016b\toolbox\matlab\external\interfaces\webservices\restful\private\encodeInputs.m
I see the error occurs on line 25
url = matlab.internal.webservices.urlencode(url, options, queryParams{:})
Error using matlab.internal.webservices.urlencode (line 46)
Too many input arguments.
where url is the url I specified, queryParams is an empty cell and options is
options =
weboptions with properties:
CharacterEncoding: 'auto'
UserAgent: 'MATLAB 9.1.0.441655 (R2016b)'
Timeout: 5
Username: ''
Password: ''
KeyName: ''
KeyValue: ''
ContentType: 'auto'
ContentReader: []
MediaType: 'application/x-www-form-urlencoded'
RequestMethod: 'get'
ArrayFormat: 'csv'
HeaderFields: []
CertificateFilename: 'C:\Program Files\MATLAB\R2016b\sys\certificates\ca\rootcerts.pem'
Can anyone help me retrieve the data from url1?
thank you

 Risposta accettata

Guillaume
Guillaume il 24 Ott 2016

0 voti

I can't reproduce the error you get with webread on R2016b (win7 but that shouldn't matter). webread returns exactly the same thing as urlread.
In any case, you won't be able to fetch the table in your first url using either. That table is generated by a script. Neither webread nor urlread can cope with dynamic content.
You're in luck though, it appears that the website has an API to fetch data. That you will be able to use with webread and it will be much easier than trying to parse html (assuming you don't run in one of the JSON parsing bugs in the current version of matlab).

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by