I am using this code to search results using the Html Agility Pack. It looks like this:
WebRequest request = WebRequest.Create(texto);
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII);
string Texto = reader.ReadToEnd();
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(Texto);
var links = doc.DocumentNode.SelectNodes("//a[contains(text(),'2')][@href]");
if (links != null)
{
foreach (HtmlNode link in links)
{
var href = link.Attributes["href"].Value;
MessageBox.Show(href);
}
}
The code idea is: Look for a tag like this:
<a href="/t439-teste">2</a>
The code I have worked correctly and get the results. The problem is that it is capturing the results that have 2 as a whole, I want it to only capture only those that have EXACTLY the 2, it alone. How?
Thanks in advance for the help.