How do I extract info from a webpage?

后端 未结 2 683
再見小時候
再見小時候 2021-01-25 04:55

I want to collect some data from the front page of a website. I can easily run through each line and it is only one specific one that I am interested in. So I want to identify t

2条回答
  •  再見小時候
    2021-01-25 05:40

    Parsing html page with regexes is wrong. Still if you know the exact structure of a single html line, you can use regex without thinking about the line as an html code.

    Assuming that the number always is within the brackets and the span with jix_channels_count class:

    Match match = Regex.Match(htmlLine, @"(\]*class=""jix_channels_count[^>]*\>\()([^)]+)(\))", RegexOptions.IgnoreCase);
    if (match.Success)
    {
        string number = match.Groups[2].Value;
    }
    

提交回复
热议问题