I have to get the HTML code of a web and after that to find this class:
<span class='uccResultAmount'>0,896903</span>
I have tried with Regular-Expressions.
And also with Streams, I mean, storing the whole HTML code in a string
. However, the code is very large for a string
. So that makes it impossible, because the amount 0,896903
I am searching does not exist in the string
.
Is there any way to only read a little block of the Stream?
A part of the method:
public static string getValue()
{
string data = "not found";
string urlAddress = "http://www.xe.com/es/currencyconverter/convert/?Amount=1&From=USD&To=EUR";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = null;
if (response.CharacterSet == null)
{
readStream = new StreamReader(receiveStream);
}
else
{
readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
}
data = readStream.ReadToEnd(); // the string in which I should search for the amount
response.Close();
readStream.Close();
}
If you find an easier way to fix my problem let me know it.