0

I want to use MATLAB to read the data from a URL which is dynamically changing. Can I do this? Here is my code:

function reading(company, signal)
url1='https://finance.yahoo.com'; 
url2='market-overview'; 
url=strcat(url1,'company',url2,'signal'); 
name=strcat(company,signal);
urlwrite('url','name.h5');

I got this error:

Either this URL could not be parsed or the protocol is not supported.

Can anyone help me ?

Makoto
  • 104,088
  • 27
  • 192
  • 230

1 Answers1

1

url, is a variable. 'url', is a string containing the letters url. You seem to be treating them as if they are interchangeable.

i.e.. when you do this:

url1='https://finance.yahoo.com'; 
url2='market-overview'; 
url=strcat(url1,'company',url2,'signal'); 

The output will always be the same regardless of the variables company and signal, because you are only passing strings, not variable names. You need:

% company and signal are names of variables you pass into your function
url=strcat(url1,company,url2,signal); 

(You ought to be able to work out, then, what the issue is with your urlwrite command).

nkjt
  • 7,825
  • 9
  • 22
  • 28
  • thanks nkjt, it works now with the strcat issue. urlwrite is that I want to read the data from this dynamic url I just created ans save it in a .h5 files. – user2307344 Oct 21 '14 at 06:11