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

  • 相关阅读:
    spring的了解以及简单框架的搭建
    动态代理
    struts2标签(转)
    使用OGNL表达式
    struts2 ValueStack
    struts2框架xml验证
    struts2 validate手动验证
    struts2自定义拦截器
    struts2文件上传
    当findById(Integer id)变成String类型
  • 原文地址:https://www.cnblogs.com/zhwl/p/1968845.html
Copyright © 2011-2022 走看看