On May 9, 5:37 am, "discounton...@gmail.com" <discounton...@gmail.com>
wrote:
I know that there is a way of searching in the html code and return
values (but don't know how)
Use Regular Expressions.
More info:
http://www.google.com/search?hl=en&q...ssions+asp.net
In your case you should get the text and parse it using patterns.
Here's the complete pattern to get the link, name, description and
price:
(?<=\<h2\>\<a\shref=\")
(?<url>(.|\n)*?)(\"\>)(?<name>(.|\n)*?)(\<\/a\></h2\>\n\<br\/\>)
(?<description>(.|\n)*?)(\n)
(.|\n)*?
(\<span\sclass\=\"price\"\>)(?<price>.*?)(\<\/span\>)
Note, in the code it has to be in one line.
Here's an example of the code:
string t = "html_from_yahoo";
string e = "(?<=\<h2\>............(\<\/span\>)";
Regex r = new Regex(e, RegexOptions.Compiled);
MatchCollection matches = r.Matches(t);
foreach (Match m in matches)
{
Response.Write("name="+match.Groups["name"]);
Response.Write("description="+match.Groups["name"]);
Response.Write("url="+match.Groups["url"]);
Response.Write("price="+match.Groups["price"]);
}
Hope it helps