views:

51

answers:

2

Is it possible to make http requests with MATLAB?

I am specifically interested in the way to make a request and store the response as a new variable.

+2  A: 

Try starting with the functions urlread and web.

High Performance Mark
+1  A: 

urlread will make an HTTP request to any URL and return the results as a char array.

For example:

>> s = urlread('http://www.mathworks.com');
>> whos s
  Name      Size               Bytes  Class    Attributes

  s         1x23346            46692  char               

Depending on exactly what you're looking to extract as a variable, you may have to further post-process the result using functions like regexp and str2double.

Matthew Simoneau
Parsing HTML with regular expressions?! Oh dear God NOOOOOO!!! (http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) ... Seriously though, this isn't such a terrible option for simple parsing conditions. ;)
gnovice

related questions