加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

提供几个关于采集的函数(ASP)

发布时间:2023-05-26 17:14:30 所属栏目:Asp教程 来源:
导读:提供几个关于采集的函数(ASP)
<%
&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;断剑注释&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&
提供几个关于采集的函数(ASP)
<%
''''''''''''''''断剑注释'''''''''''''''''''''''''
''''strText为要切取内容的那段打的内容''''''''''''
''''strStarTag为要切取内容的开始的地方''''''''''
''''strEndTag为要切取内容的结束的地方''''''''''
''''GetText返回值为切取出来的内容''''''''''''''
'''''''''''''''注释结束''''''''''''''''''''''''
Function GetText(strText, strStartTag, strEndTag)
dim intStart
intStart = instr(strText, strStartTag)
if intStart then
intStart = intStart + len(strStartTag)
intEnd = InStr(intStart, strText, strEndTag)
GetText = Mid(strText, intStart, intEnd - intStart)
else
GetText = " "
end if
End Function

%>
<%
'''''''''断剑注释''''''''''''
'''''''''以下的函数都可以不管'''''''''
''''''''只管入口函数getHTTPPage'''''''
''''''''path为要读取的网页地址''''''''
''''''''getHTTPPage返回读取到的网页内容''
''''''''这里应该注意的是gb2312这里,如果被读取的网页编码是
''gb2312就用gb2312,如果是UTF-8的话,就换成UTF-8''''
''''''''注释结束''''''''''
Function getHTTPPage(Path)
t = GetBody(Path)
getHTTPPage=BytesToBstr(t,"gb2312")
End function

Function GetBody(url)
on error resume next
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "get", url, False, "", ""
.Send
GetBody = .ResponseBody
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章