I would like to capture the label value of the web page. For example, the web page will be opened everyday once and the value of the label id="lblTest" can be captured automatically without manual record.
May i know how can I do this by using C# language and ASP.net? The web page doesn't has any API for me to retrieve the data.
Thank you very much.
You can use HTML Agility Pack.
You can try with this.
using System.Net;
using System.Text.RegularExpressions;
public string GetLabelValue(string url)
{
// download your web page content
WebClient client = new WebClient();
string downloadString = client.DownloadString(url);
// regular expression
var pattern = @"<label.+id=""lblTest"".{0,}>(.+)</label>";
var match = Regex.Match(downloadString, pattern, RegexOptions.IgnoreCase);
// getting the label value
var labelValue = match.Groups[1].Value;
return labelValue;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.