Home > utility > getHomePage.m

getHomePage

PURPOSE ^

getHomePage: Get homepage from a given url address

SYNOPSIS ^

function contents=getHomePage(urlAddress)

DESCRIPTION ^

 getHomePage: Get homepage from a given url address
    Usage: contents = getHomePage(urlAddress)
        contents: Retrieved contents
        urlAddress: URL to get

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function contents=getHomePage(urlAddress)
0002 % getHomePage: Get homepage from a given url address
0003 %    Usage: contents = getHomePage(urlAddress)
0004 %        contents: Retrieved contents
0005 %        urlAddress: URL to get
0006 
0007 %    This function uses Java to retrieve a homepage.
0008 %    An easier alternative is to use "urlread" that comes with MATLAB 6.5
0009 
0010 %    Roger Jang, 20030707
0011 
0012 if nargin<1
0013     urlAddress = 'http://www.mathworks.com/support/tech-notes/1100/1109.shtml';
0014     urlAddress = 'http://neural.cs.nthu.edu.tw/jang';
0015 end
0016 fprintf('Getting homepage contents from "%s"...', urlAddress);
0017 
0018 url = java.net.URL(urlAddress);
0019 is = openStream(url);
0020 isr = java.io.InputStreamReader(is);
0021 br = java.io.BufferedReader(isr);
0022 
0023 lineNum = 1;
0024 while 1
0025     line = readLine(br);
0026     if isempty(line), break, end
0027     temp = cell(line);
0028     contents{lineNum} = xlate(temp{1});
0029 %    fprintf('lineNum=%d\n', lineNum);
0030 %    fprintf('line=%s\n', temp{1});
0031     lineNum = lineNum+1;
0032 end
0033 
0034 fprintf('    Done!');

Generated on Tue 01-Jun-2010 09:50:34 by m2html © 2003