2016-12-07 5 views
0

私はウェブページのラベル値を取得したいと思います。 たとえば、Webページは毎日開かれ、ラベルid = "lblTest"の値は手動で記録されることなく自動的に取得されます。どのようにC#を使用してWebページの特定のフィールド値をキャプチャするには?

私はC#言語とASP.netを使用してこれを行う方法を知っていますか? Webページには私がデータを取得するためのAPIはありません。

ありがとうございました。

+1

[C#とHTMLAgilityでWebページを削れ]の可能複製(http://stackoverflow.com/questions/5320231/scraping-a-webpage-with-c-sharp-and-htmlagility) – Amy

+0

あなたがありますwebformsを使用して? \t \t \t \t \t ASN Zinov

答えて

0

HTMLアジリティパックを使用できます。

Here

0

これで試すことができます。

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; 
} 
+0

<= "0" ボーダー= "0" ID = "GridView1" テーブルCELLSPACING> = "61"> 0.6852 5.00 - \t \t こんにちは、これはdownloadStringです私はこれをうまく捕らえていました。しかし、GridView形式であり、異なる列と行を含んでいるので、テーブルの各値をどのように取得するのですか。 –

関連する問題