<% '正则表达式的HTML分离函数
Function stripHTML(strHTML) 'Strips the HTML tags from strHTML
Dim objRegExp, strOutput Set objRegExp = New Regexp
objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<.+?>"
'Replace all HTML tag matches with the empty string strOutput = objRegExp.Replace(strHTML, "")
'Replace all < and > with < and > strOutput = Replace(strOutput, "<", "<") strOutput = Replace(strOutput, ">", ">")
stripHTML = strOutput 'Return the value of strOutput
Set objRegExp = Nothing End Function %>
<head><title>怎样取出网页里的部分内容</title></head> <% on error resume next Private d_exsit Dim Retrieval Dim TakenHTML
Function GetHtml(url) Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP") With Retrieval .open "GET", url, False, "", "" .Send GetHtml = .responsebody End With Set Retrieval = Nothing End Function
Function bin2str(binstr) Dim varlen,clow,ccc,skipflag skipflag=0 ccc = "" varlen=LenB(binstr) For i=1 To varlen If skipflag=0 Then clow = MidB(binstr,i,1) If AscB(clow) > 127 Then ccc =ccc & Chr(AscW(MidB(binstr,i+1,1) & clow)) skipflag=1 Else ccc = ccc & Chr(AscB(clow)) End If Else skipflag=0 End If Next bin2str = ccc End Function
TakenHTML = GetHtml("http://www.eyou.com") TakenHTML=bin2str(TakenHTML)
titl=InStr(1,takenhtml,"<title>",1) titll=InStr(1,takenhtml,"</title>",1) title=mid(takenhtml,titl,titl1)
fon=InStr(1,takenhtml,"<font class='STitle'>",1) fonn=InStr(1,takenhtml,"</font>",1) font=mid(takenhtml,fon,fonn)
pp=InStr(1,takenhtml,"<p class=content>",1) ppp=InStr(1,takenhtml,"</p>",1) pppp=mid(takenhtml,pp,ppp) %>
|