提取网页中的内容(提取纯文字VB)

 

'**************************************************
'
函数名:distill
'
作     用:提取网页中的内容
'
参     数:content ---- 要提取的内容,length ---- 从开头数要提取的字符数
'
返回值:提取的内容
'
**************************************************
function distill(content,length)
    
ON ERROR RESUME NEXT
    
dim isWord,okContent,i
    i
=1
    isWord
=false
    content
=replace(content," ","")
    
do while len(okContent)<length
     
if mid(content,i,1)<>"<" then
         isWord
=true
     
else
         i
=i+1
         
do while mid(content,i,1)<>">"
             i
=i+1
         
loop
         i
=i+1
         
if mid(content,i,1)<>"<" then
             isWord
=true
         
else
             isWord
=false
         
end if
     
end if
     
if i>len(content) then
         distill
=okContent
         
exit function
     
end if
     
if isWord then
         okContent
=okContent+mid(content,i,1)
         i
=i+1
     
end if
    
loop
    distill
=okContent
    
if err.number<>0 then err.clear
end function
posted @ 2009-03-25 18:09  Michael.Z  阅读(5218)  评论(0编辑  收藏  举报