asp 小偷 采集 类 函数 常用 必须 截取 编码转换
<%
'==================================================
'函数名:GetHttpPage
'作 用:获取网页源码
'参 数:HttpUrl ------网页地址
'==================================================
Function GetHttpPage(HttpUrl)
If IsNull(HttpUrl)=True or Len(HttpUrl)<18 or HttpUrl="$False$" Then
GetHttpPage="$False$"
Exit Function
End If
Dim Http
Set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",HttpUrl,False
Http.Send()
If Http.Readystate<>4 then
Set Http=Nothing
GetHttpPage="$False$"
Exit function
End if
GetHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
Set Http=Nothing
If Err.number<>0 then
Err.Clear
End If
End Function
'==================================================
'函数名:BytesToBstr
'作 用:将获取的源码转换为中文
'参 数:Body ------要转换的变量
'参 数:Cset ------要转换的类型
'==================================================
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
'==================================================
'函数名:PostHttpPage
'作 用:登录
'==================================================
Function PostHttpPage(RefererUrl,PostUrl,PostData)
Dim xmlHttp
Dim RetStr
Set xmlHttp = CreateObject("Msxml2.XMLHTTP")
xmlHttp.Open "POST", PostUrl, False
XmlHTTP.setRequestHeader "Content-Length",Len(PostData)
xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlHttp.setRequestHeader "Referer", RefererUrl
xmlHttp.Send PostData
If Err.Number <> 0 Then
Set xmlHttp=Nothing
PostHttpPage = "$False$"
Exit Function
End If
PostHttpPage=bytesToBSTR(xmlHttp.responseBody,"GB2312")
Set xmlHttp = nothing
End Function
'=================================================
相关文档:
上次写到asp,php空间有关数据库选择的问题。对于数据库的搭配 一般是这样 asp+access/ asp+sql server,然后是php+mysql。access是可以和网页空间共享大小的,而sql server 和mysql是要单独购买的。对于一般的小应用,用asp+access就可以搞定了。或者是.net+access。 这些 几乎就不要考虑数据库成本了。但是使用php的话,就 ......
<% '---调用WebService 获取Exchange2007已知用户的邮件未读数
'---参数说明----
'url:webservice 的路径
'params:方法参数
'method:方法名称
'dataType:返回的数据类型
function webServices(url,params,method,dataType)
set objXML=Server.CreateObject("MSXML2.XMLHTTP")
objXML.open "post& ......
本文链接:http://www.oversteper.com/wprogram/asp/826.html
ASP 定义常量的方法
常量:用一种名称代替数字和字符串,且其值保持一直不变。
在 VBscript 中,可以用 const 语句来定义常量。
常量分数字型和字符串型。
表示日期的常量写在两个 # 之间。
示例:
以下为引用内容:
<%@LANGUAGE="VBSCRIPT" CODEPAG ......
本文链接:http://www.oversteper.com/wprogram/asp/828.html
条件语句之 select case 语句
1、多条件分支的时候优先使用select case结构;
2、数字的大量列举时最好使用select case
3、必须使用 end select 来结束分支结构
示例:
以下为 ......
本文链接:http://www.oversteper.com/wprogram/asp/830.html
do ... loop 语句两种格式的示例
do whil ... loop :
以下为引用内容:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt ......