Retrieving data from a web page

243 ビュー (過去 30 日間)
Enrico Scupola
Enrico Scupola 2018 年 5 月 13 日
コメント済み: Enrico Scupola 2018 年 5 月 20 日
Hi all, I am having troubles in retrieving some data from this website I am not very experienced in programming and it is the first time I try getting data from the web this way. I read quite a few posts but I don't get what an API is and the issues related to the webpage formats.
To put it simply, I'd like to tell MATLAB to go on the stated webpage, to put the word 'CompanyName'(ex.Novartis) into the search bar, retrieve the resulting table and save it in a usable format (csv for example).
I run this code but it doesn't work.
url = '';
options = weboptions('Keyname','Novartis','Keyvalue','text','ContentType','auto');
data = webread(url,options);
Could anyone help me, please? Thanks.


Paolo 2018 年 5 月 13 日
Hi Enrico, try the following:
url = '';
prompt = 'Enter company of interest:';
val = input(prompt,'s');
url = strcat(url,val,'.csv');
options = weboptions('RequestMethod','get','ArrayFormat','csv','ContentType','text');
data = webread(url,options);
disp('CSV formatted data:');
disp('No information found.');
If by 'inserting the name of the company in the search bar' you meant just changing the URL, then the code above should do the trick. Simply specify the term of interest and it will retrieve the data for you.
On the other hand, if you were asking for a code which fills in the HTML form with a POST request, and retrieves the resulting data afterwards with a GET request, some changes would need to be made. Let me know.
  3 件のコメント
Enrico Scupola
Enrico Scupola 2018 年 5 月 20 日
Thanks a lot Paolo, that really helped me!


その他の回答 (0 件)




Community Treasure Hunt

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

Start Hunting!

Translated by