Shiny Language Reference
Language Reference > Web Functions
wreadline
bool wreadline(web WebVar, string Dest);
Synonyms:
bool webreadline(web WebVar, string Dest);
Reads a line from a website
The FREADLINE statement reads a single line from a URL resource previously opened by WOPEN.
The WOPEN and FREADLINE statements operate on "raw" HTTP connections. Therefore when you open and read the first line of a URL you will receive the HTTP header, followed by the raw HTML. A sequence of data may look like this:
GET / HTTP/1.1
Host: www.amazingbrass.co.uk
Connection: close
Accept-Encoding: gzip
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7
<html>
<head>
....remainder of html....The data above is a sample of what you may receive, the actual data is dependant on the webserver, any error conditions etc. It is your responsibility to process this data as you see fit, in other words if you only require the HTML "web page" part of the HTTP data then you must loop through the data received until you find the <HTML> tag.
Parameters
WebVar
A variable declared as type WEB which has previously been associated with a website by using WOPEN.
Dest
A string variable that receives the line of text read from the site.
Return Value
TRUE if reading from the site suceeded and there is further data left. Testing for FALSE is used to determine if the end of the resource has been reached.
Example Code
web MySite;
if(wopen(MySite, "http://www.amazingbrass.co.uk") == TRUE)
{
 bool bMoreData = TRUE;
 
 while(bMoreData)
 {
   // DataIn receives each line of text from the site
   string DataIn;
   bMoreData = wreadline(MySite, DataIn);
   if(strfind(DataIn, "<html>") != -1)
   {
     // The start of the HTML data has been found
   }
 }
}