如何取如下网页代码中的关键词语?
如何取如下网页代码中的关键词语?
新浪微博中的代码如下:
<DIV node-type="userListBox" ucardconf="type=1">
<UL style="WIDTH: 540px" class=cnfList node-type="userList">
<LI class="clearfix W_linecolor" action-type="itmeClick" action-data="uid=2827825121&fnick=平朕特&sex=m">
<DIV class=left>
<P class="face mbspace"><A title=平朕特 href="/u/2827825121" target=_blank><IMG alt=平朕特 src="http://tp2.sinaimg.cn/2827825121/50/22819765660/1" width=50 height=50 usercard="id=2827825121"></A></P><A class=webim_online href="javascript:;" suda-data="key=tblog_otherprofile_v4&value=chat" action-type="webim.conversation" action-data="uid=2827825121&nick=平朕特&online_state=1">聊天</A> </DIV>
<DIV class="con clearfix">
<DIV class=con_right>
<P class="addbtn mbspace"><A class=W_needbtn href="javascript:;" diss-data="refer_sort=followed" item-func="addFollow"><IMG class="addicon addicon_a" alt="怎么取如下网页代码中的关键词语" src="http://img.t.sinajs.cn/t4/style/images/common/transparent.gif"><EM class=vline></EM><IMG class=addicon alt="怎么取如下网页代码中的关键词语" src="http://img.t.sinajs.cn/t4/style/images/common/transparent.gif">加关注</A> </P>
<P class="txt mbspace"><A href="javascript:;"><EM item-func="removeFans">移除粉丝</EM></A> </P>
<P class="txt mbspace"><A onclick="javascript:window.open('http://service.account.weibo.com/reportspam?rid=2827825121&type=3&url=http%3A%2F%2Fweibo.com%2F2919369134%2Ffans&bottomnav=1&wvr=4', 'newwindow', 'height=700, width=550, toolbar =yes, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');" href="javascript:void(0);">举报</A> </P></DIV>
<DIV class=con_left>
<P class="name mbspace"><A class=W_f14 href="/u/2827825121" target=_blank usercard="id=2827825121">平朕特</A> <SPAN class=addr><IMG class=male title=男 alt="怎么取如下网页代码中的关键词语" src="http://img.t.sinajs.cn/t4/style/images/common/transparent.gif" width=11 height=12>河北 邯郸 </SPAN></P>
<P class="connect mbspace">关注 <A href="/2827825121/follow" target=_blank>97</A><I class=W_vline>|</I>粉丝 <A href="/2827825121/fans" target=_blank>2</A><I class=W_vline>|</I>微博 <A href="/u/2827825121" target=_blank>18</A></P>
<P class="weibo mbspace"><A class=W_linkb href="/u/2827825121">//@平朕特: 为了天下的母亲(今天 16:06)</A></P>
<P class="from W_textb">通过<A class=W_linkb href="http://weibo.com/">新浪微博</A>关注 </P>
<P class=more_info><A class=W_moreup title=更多资料 href="javascript:;" item-func="moreData">更多资料<SPAN class=more></SPAN></A></P></DIV></DIV>
<DIV class=detail>
<DIV class="W_bubtips clearfix">
<DIV class=W_bgcolor_arrow><EM class=W_arrline_mini>◆</EM><SPAN>◆</SPAN></DIV>
<DIV class="W_bgcolor W_linecolor" node-type="dataContent">
<P class=mbdetail>学校:<A title=河北传媒学院 href="http://s.weibo.com/user/&school=%E6%B2%B3%E5%8C%97%E4%BC%A0%E5%AA%92%E5%AD%A6%E9%99%A2">河北传媒学院</A></P>
<P class=mbdetail>我关注的人中:<A href="/u/2755832625">0一米海岸线0</A>、<A href="/u/2755018803">红旗劲舞</A>、<A href="/u/2932082924">如意红木家具8</A> 关注了他</P>
<P>我们共同关注:<A href="/u/2615835427">美丽的金牛座行者</A>、<A href="/u/2432482141">IAMyhc</A>、<A href="/u/2932082924">如意红木家具8</A>等<A href="/2827825121/follow?tag=1">8人</A></P></DIV></DIV></DIV></LI>
<LI class="clearfix W_linecolor" action-type="itmeClick" action-data="uid=2885849041&fnick=DennisTing-TW&sex=m">
<DIV class=left>
<P class="face mbspace"><A title=DennisTing-TW href="/u/2885849041" target=_blank><IMG alt=DennisTing-TW src="http://tp2.sinaimg.cn/2885849041/50/5637245555/1" width=50 height=50 usercard="id=2885849041"></A></P><A class=webim_leave href="javascript:;" suda-data="key=tblog_otherprofile_v4&value=chat" action-type="webim.conversation" action-data="uid=2885849041&nick=DennisTing-TW&online_state=0">私信</A> </DIV>
<DIV class="con clearfix">
<DIV class=con_right>
<P class="addbtn mbspace"><IMG class=icon_connect title=已相互关注 src="http://img.t.sinajs.cn/t4/style/images/common/transparent.gif"> </P>
<P class="txt mbspace"><A href="javascript:;"><EM item-func="removeFans">移除粉丝</EM></A> </P>
<P class="txt mbspace"><A onclick="javascript:window.open('http://service.account.weibo.com/reportspam?rid=2885849041&type=3&url=http%3A%2F%2Fweibo.com%2F2919369134%2Ffans&bottomnav=1&wvr=4', 'newwindow', 'height=700, width=550, toolbar =yes, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');" href="javascript:void(0);">举报</A> </P></DIV>
<DIV class=con_left>
<P class="name mbspace"><A class=W_f14 href="/u/2885849041" target=_blank usercard="id=2885849041">DennisTing-TW</A> <SPAN class=addr><IMG class=male title=男 alt="怎么取如下网页代码中的关键词语" src="http://img.t.sinajs.cn/t4/style/images/common/transparent.gif" width=11 height=12>北京 </SPAN></P>
<P class="connect mbspace">关注 <A href="/2885849041/follow" target=_blank>26</A><I class=W_vline>|</I>粉丝 <A href="/2885849041/fans" target=_blank>24</A><I class=W_vline>|</I>微博 <A href="/u/2885849041" target=_blank>14</A></P>
<P class="info mbspace">简介:進入我的博客進入營銷管理入門,貼近市場做好基礎建設</P>
<P class="weibo mbspace"><A class=W_linkb href="/u/2885849041">我在#北京乐活城有机健康生活馆(旗舰店)# 今天是生日慶第2天,吃吃喝喝少不了....員工依舊熱情補貨等待顧客來開party http://t.cn/zWlOWCl(8月11日 09:05)</A></P>
<P class="from W_textb">通过<A class=W_linkb href="http://m.weibo.com/web/cellphone.php#android">Android客户端</A>关注 </P>
<P class=more_info><A class=W_moredown title=更多资料 href="javascript:;" item-func="moreData">更多资料<SPAN class=more></SPAN></A></P></DIV></DIV>
如何取得“平朕特”“DennisTing-TW”这两个粉丝的名字呢?网页其它代码同上。
谢谢`
[解决办法]
'┏〓〓〓〓〓〓〓〓〓 findallstrbetween,start 〓〓〓〓〓〓〓〓〓┓
Function findallstrbetween(bystr, findstr, findstr2, Optional startid As Long = -1, Optional findbackfirst As Boolean)
'VB源码,帮你写函数,帮你写代码,帮你写模块,帮你设计软件
'--需要什么函数或功能,可以联系我。
'版权所有,请保留作者信息.QQ:1085992075
'如需商业用途请联系作者
'分解htm参数xx=??
On Error GoTo err
Dim Sz()
Dim szaddcount As Integer
Dim szcount As Integer
szaddcount = 20
ReDim Sz(szaddcount)
szcount = -1
Dim id1 As Long, id2 As Long
Dim str As String
str = bystr
'MsgBox str
id1 = 1
If startid = -1 Then
startid = InStr(str, findstr)
Else
startid = 1
End If
While id1 > 0
If findbackfirst Then
id2 = InStr(startid, str, findstr2)
If id2 = 0 Then GoTo dook
id1 = InStrRev(str, findstr, id2 - 1)
If id1 = 0 Then GoTo dook
startid = id1 - Len(findstr2)
Else
id1 = InStr(startid, str, findstr)
If id1 = 0 Then GoTo dook
id2 = InStr(id1 + Len(findstr), str, findstr2)
'新改11-11
If id2 = 0 Then GoTo dook
End If
startid = id2 + Len(findstr2)
szcount = szcount + 1
Sz(szcount) = Mid(str, id1 + Len(findstr), id2 - id1 - Len(findstr))
'MsgBox startid
Wend
dook:
If Not (szcount = -1) Then ReDim Preserve Sz(szcount): findallstrbetween = Sz
Exit Function
err:
If err.Number = 9 Then
ReDim Preserve Sz(UBound(Sz) + szaddcount)
Resume
End If
End Function
'┗〓〓〓〓〓〓〓〓〓 findallstrbetween,end 〓〓〓〓〓〓〓〓〓┛