<A onclick=view(0); href="http://ssbh.com/;rtype=r&amp;mtype=3&amp;delay=#">1</A>我通过mshtml.IHTMLElement e1找到这个HTML元素,并可以通过sStre1=e1.getAttribute("href",1).ToString();提取href中的字符串(="http://ssbh.com/;rtype=r&amp;mtype=3&amp;delay=#"),我现在想提取onclick的字符串(即“view(0)”通过e1.getAttribute("onclick",1).ToString()不行),该怎么做呀,请大家帮忙,谢谢。

解决方案 »

  1.   

    通过正则表达式来提取.
    前面是onclick=后面是;结束的即可
    Match match=Regex.Match("文本",@"(?<=onclick\=).+(?=;\s)",RegexOptions.IgnoreCase);
      

  2.   

    可是网页里面有多个A元素
    <A onclick=view(0); href="http://ssbh.com/;rtype=r&amp;mtype=3&amp;delay=#">1</A>
    <A onclick=view(1); href="http://ssbh.com/;rtype=r&amp;mtype=3&amp;delay=#">1</A>
    <A onclick=view(2); href="http://ssbh.com/;rtype=r&amp;mtype=3&amp;delay=#">1</A>
    我主要目的是想区分出0.1.2