EDN Admin
Well-known member
I have this code:
<pre class="prettyprint private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
WebRequest request = WebRequest.Create(url);
request.Method = "GET";
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string content = reader.ReadToEnd();
string html = content;
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
var link = doc.DocumentNode.Descendants()
.Select(d => d.Attributes["href"].Value)
.First();
reader.Close();
response.Close();
}[/code]
Content now contain a lot of source data.
Somewhere in the middle i have for example this line:
<pre class="prettyprint <span class="message-profile-name" ><a href=/profile/daniel>daniel : <span class="message-text hello everyone<wbr/> <img class=emoticon emoticon-tongue src=/t.gif/>[/code]
I want to loop or move over all the content text and take out each time every place in the content that have text after the profile and the text
For example from this line i want to take out only: daniel hello everyone
But what i need to do is to take all the text in the content in this places.
And i also need to make that it will keep update/download the content over and over again since this text the profile and the text after it change all the time.
So what i need is :
1. Loop all over the content variable and take out the text in the specific places i mentioned above.
2. To update/download the content each n seconds and again extract the text from this places and to check that if the text is the same dont extract it dont keep it.
How can i do it ?
Thanks.
<hr class="sig danieli
View the full article
<pre class="prettyprint private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
WebRequest request = WebRequest.Create(url);
request.Method = "GET";
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string content = reader.ReadToEnd();
string html = content;
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
var link = doc.DocumentNode.Descendants()
.Select(d => d.Attributes["href"].Value)
.First();
reader.Close();
response.Close();
}[/code]
Content now contain a lot of source data.
Somewhere in the middle i have for example this line:
<pre class="prettyprint <span class="message-profile-name" ><a href=/profile/daniel>daniel : <span class="message-text hello everyone<wbr/> <img class=emoticon emoticon-tongue src=/t.gif/>[/code]
I want to loop or move over all the content text and take out each time every place in the content that have text after the profile and the text
For example from this line i want to take out only: daniel hello everyone
But what i need to do is to take all the text in the content in this places.
And i also need to make that it will keep update/download the content over and over again since this text the profile and the text after it change all the time.
So what i need is :
1. Loop all over the content variable and take out the text in the specific places i mentioned above.
2. To update/download the content each n seconds and again extract the text from this places and to check that if the text is the same dont extract it dont keep it.
How can i do it ?
Thanks.
<hr class="sig danieli
View the full article