读书人

怎么获取html中特定字符串中的值

发布时间: 2012-04-12 15:46:35 作者: rapoo

如何获取html中特定字符串中的值?
如下所示,该文本存储在txt中,现在需要获取该用户的收录数,如:<A title=收录他的名单64771个 href="http://t.qq.com/list_hison.php?u=liuxiang">中的"64771”,其他txt中“收录他”可能是“收录她”、“收录它”。
或者获取<STRONG class=listNum rel="liuxiang">64771</STRONG>标签中的数字“64771”也可以。

HTML:
<DIV class=w_head_outer>
<DIV class=headWrap>
<DIV id=header class=headInside>
<H1><A accessKey=z title=t.qq.com href="http://t.qq.com/sky_2011_sky" boss="btnClickNewLogo">腾讯微博</A> </H1>
<UL id=topNav class=topNav>
<LI class=topNavItem><A href="http://t.qq.com/sky_2011_sky"><U>首页</U><I></I></A> </LI>
<LI class=topNavItem><A href="http://t.qq.com/c/default"><U style="PADDING-RIGHT: 15px">广场</U><I></I></A><SUP class=ico_new_sr></SUP> </LI>
<LI class="topNavItem groups"><A href="http://qun.t.qq.com" boss="btnTopMenuGroup"><U>微群<EM> </EM></U><I></I></A> </LI>
<LI class=topNavItem><A href="http://t.qq.com/people"><U>找人</U><I></I></A> </LI>
<LI id=app class="topNavItem apps"><A href="http://app.t.qq.com" boss="btnTopMenuApp"><U>应用<EM> </EM></U><I></I></A> </LI>
<LI class=topNavItem><A href="http://p.t.qq.com/client.php?t=mobile"><U>手机</U><I></I></A> </LI></UL>
<UL class="topNav right">
<LI style="DISPLAY: none" class="topNavItem countItem topNavMsg"><A class="defaultCur txt" title=消息 href="#"><U><STRONG>0</STRONG></U><I></I></A> </LI>
<LI id=topNav1 class="topNavItem accountItem"><A class=txt title=杨显(@sky_2011_sky) onclick="if(document.body.className.indexOf('ipad') != -1){this.nextSibling.style.display='block';this.className+=' active';return false}" href="http://t.qq.com/sky_2011_sky?preview"><U>杨显<EM> </EM></U><I></I></A>
<UL style="DISPLAY: none" class=topNavSub>
<LI><A href="http://t.qq.com/setting" boss="btn_settingNewNav">设置</A> </LI>
<LI><A id=setTheme title=皮肤设置 onmousedown=window.scrollTo(0,0); href="#" boss="btn_themeNewNav">换肤</A> </LI>
<LI><A href="http://t.qq.com/help.php">帮助</A> </LI>
<LI><A href="http://t.qq.com/logout.php">退出</A> </LI></UL></LI></UL>
<DIV class=tSearchNew>
<FORM id=searchForm method=get action=http://t.qq.com/search/index.php><LABEL for=searchKey>搜他的广播/搜全站</LABEL><INPUT accessKey=s id=searchKey class=inputTxtNew maxLength=50 name=k autocomplete="off"> <INPUT value=174 type=hidden name=pos> <INPUT class=inputBtn value=搜索 type=submit> <A class=btn_ldrop href="#"><EM></EM></A></FORM></DIV>
<DIV id=nav_pub_wrap class=nav_pub_wrap><A class=btn_nav_pub title=写微博 href="#"><EM class=nav_pub_btn>写微博</EM><B class=nav_pub_bg1></B><B class=nav_pub_bg2></B> </A></DIV></DIV><A style="Z-INDEX: 101; POSITION: absolute; FONT-SIZE: 14px; TOP: 7px; RIGHT: 20px" id=testVersion class=testVersion href="http://1.t.qq.com" boss="btn_gotoNanoVersion">体验版<SPAN class=ico_new_sr><EM></EM></SPAN></A>
<DIV class=headShadow></DIV></DIV></DIV>
<DIV id=topWrap>


<DIV style="DISPLAY: none" id=talkBoxMsg>
<TABLE class=letterBg border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TH>收信人</TH>
<TD>
<DIV class=txtWrap><INPUT id=userName class="msgTo inputTxt" value=刘翔 name=userName> <SPAN class=cNote>请输入你的听众的微博帐号</SPAN></DIV></TD></TR>
<TR>
<TH>内 容</TH>
<TD>
<DIV class=txtWrap><TEXTAREA class="inputArea noAutoCmt" type="text"></TEXTAREA></DIV></TD></TR>
<TR>
<TH></TH>
<TD><INPUT class="sendBtn inputBtn" title="快捷键 Ctrl+Enter" value=发送 type=button><SPAN class=countTxt>还能输入<EM>140</EM>字</SPAN><A class=ico_face title=表情 href="#"></A></TD></TR></TBODY></TABLE></DIV>
<DIV id=mainWrapper class=clear>
<DIV class=main>
<STYLE type=text/css>
#LUI .funBox .right{width:186px;}
</STYLE>

<DIV id=LUI>
<UL class=clear>
<LI class=pic><A title=刘翔(@刘翔) onclick="if(MI.Face){return false}" href="http://t.qq.com/liuxiang"><IMG title=点击查看大图 onclick="if(MI.Face){MI.Face.view(this);MI.Bos('btnFaceViewBig');}" alt=刘翔 onerror=MI.picError(this) src="http://t1.qlogo.cn/mbloghead/672fc152e3fa89784842/180"></A></LI>
<LI class=detail>
<H4><SPAN class=userName>刘翔</SPAN><A class=vip title=腾讯个人认证 href="http://t.qq.com/certification" target=_blank></A><A class="tIcon ico_yue" title=助力奥运,与好友一起传递宝马悦图标 href="http://jump.t.l.qq.com/ping?target=http%3A//bmwolympic.qq.com/joy&cpid=641009536&type=12" target=_blank></A><A class="ico_level wbL5" href="http://p.t.qq.com/levelDetail.php?u=liuxiang" user="liuxiang"><EM>5</EM></A><A class=ico_qvip title=微博红人 onclick="MI.Bos('btnIconQvip')" href="http://t.qq.com/k/%25E5%25BE%25AE%25E5%258D%259A%25E7%25BA%25A2%25E4%25BA%25BA"></A><SPAN class=left>(@刘翔)</SPAN><SPAN id=addNote class=funType>[<A onclick="MI.Note.add(this);return false" href="#" chName="刘翔" account="liuxiang" nick="刘翔" note="">添加备注</A>]</SPAN><BR><A class=link href="http://t.qq.com/liuxiang">http://t.qq.com/liuxiang</A></H4>
<DIV class=userNums><A href="http://t.qq.com/liuxiang">广播<STRONG>2305</STRONG>条</A><SPAN>|</SPAN><A href="http://t.qq.com/liuxiang/follower">听众<STRONG class=followNum rel="liuxiang">25141831</STRONG>人</A><SPAN>|</SPAN><A href="http://t.qq.com/liuxiang/following">他收听<STRONG>47</STRONG>人</A><SPAN>|</SPAN><A title=收录他的名单64771个 href="http://t.qq.com/list_hison.php?u=liuxiang">收录他<STRONG class=listNum rel="liuxiang">64771</STRONG></A></DIV>......

[解决办法]
正则:收录(他|她)的名单\d+个

读书人网 >C#

热点推荐