//GetExchangeRates
error :
static void getExchangeRates(Args _args)
{
int curPos, endPos, startPos;
TextBuffer tb = new TextBuffer();
System.Net.WebRequest webRequest;
System.Net.WebResponse webResponse;
str page;
System.IO.StreamReader streamReader;
try
{
webRequest = System.Net.WebRequest::Create("http://www.x-rates.com/d/INR/table.html");
// this will throw an webexception if cannot be reached.
webResponse = webRequest.GetResponse();
streamReader = new System.IO.StreamReader(webResponse.GetResponseStream());
tb.setText('');
page = streamReader.ReadToEnd();
streamReader.Close();
tb.setText(page);
curpos = 1;
startPos = 1;
tb.regularExpressions(false);
tb.find('<a href="/d/INR/EUR/graph120.html" class="menu">', curpos);
startpos = tb.matchPos();
tb.find('</a> </font></td>', startpos);
endpos = tb.matchPos();
page = tb.subStr(startpos, endpos - startpos);
info(strFmt("1 EUR = %1 INR",strreplace(page,'<a href="/d/INR/EUR/graph120.html" class="menu">','')));
// Close the webResonse
webResponse.Close();
}
catch(Exception::CLRError)
{
throw error(AifUtil::getClrErrorMessage());
}
}
error :
static void getExchangeRates(Args _args)
{
int curPos, endPos, startPos;
TextBuffer tb = new TextBuffer();
System.Net.WebRequest webRequest;
System.Net.WebResponse webResponse;
str page;
System.IO.StreamReader streamReader;
try
{
webRequest = System.Net.WebRequest::Create("http://www.x-rates.com/d/INR/table.html");
// this will throw an webexception if cannot be reached.
webResponse = webRequest.GetResponse();
streamReader = new System.IO.StreamReader(webResponse.GetResponseStream());
tb.setText('');
page = streamReader.ReadToEnd();
streamReader.Close();
tb.setText(page);
curpos = 1;
startPos = 1;
tb.regularExpressions(false);
tb.find('<a href="/d/INR/EUR/graph120.html" class="menu">', curpos);
startpos = tb.matchPos();
tb.find('</a> </font></td>', startpos);
endpos = tb.matchPos();
page = tb.subStr(startpos, endpos - startpos);
info(strFmt("1 EUR = %1 INR",strreplace(page,'<a href="/d/INR/EUR/graph120.html" class="menu">','')));
// Close the webResonse
webResponse.Close();
}
catch(Exception::CLRError)
{
throw error(AifUtil::getClrErrorMessage());
}
}
No comments:
Post a Comment