zoukankan      html  css  js  c++  java
  • 网页抓取(正则表达式)

    引言: 网页 抓取后 需要用正则表达式获取内容

    我实验了一个例子 怕忘记 先记在这里 (不是完整的网页抓取的解决方案 大家谅解)

    如果想取字符串中的value的值 可以这么做

    string S=@"
    <input type=hidden name=bs value='C8ADC15E27FB3838EFC92AAA9B9672729DD7F639A7A3750B970FD72BC54BD685A8DF4740022B27EF95A632D5D1CC230DAAB0ED1E7B6FF82AF6EB54CCAB89'>
    <input type=hidden name=str3 value='BA24925B461A004EFDE758506E7F551E'>
    <input type=hidden name=str4 value='39504033001986423360'>
    <input type=hidden name=lm value='20998' > ";
            Regex Re = new Regex(@"value=(.*?)\s", RegexOptions.IgnoreCase);
            MatchCollection Mc = Re.Matches(S);

            if (Mc.Count == 0)
            {
              
                throw new Exception();
            }
            foreach (Match M in Mc)
            {
                string a = M.Groups[1].Value;
              
            }

  • 相关阅读:
    dup和dup2
    cassandra nodetools
    python 之mechanize
    IDEA使用GsonFormat
    游标应用
    SQL 2005 with(nolock)详解
    SET NOCOUNT ON
    异常处理机制(Begin try Begin Catch)
    FILLFACTOR 作用 sql
    触发器语法
  • 原文地址:https://www.cnblogs.com/zhwl/p/1968845.html
Copyright © 2011-2022 走看看