% '函数名:GetResStr '作用:获取指定URL的HTML代码 '参数:URL-要获取的URL function GetResStr(URL) err.clear dim ResBody,ResStr,PageCode,ReturnStr Set Http=createobject("MiCROSOFT.XMLHTTP") Http.open "GET",URL,False Http.Send() If Http.Readystate =4 Then If Http.status=200 Then ResStr=http.responseText ResBody=http.responseBody ReturnStr=BytesToBstr(http.responseBody,"gb2312") GetResStr=ReturnStr End If End If End Function '函数名:BytesToBstr '作用:转换二进制数据为字符 '参数:Body-二进制数据,Cset-文本编码方式 Function BytesToBstr(Body,Cset) Dim Objstream Set Objstream = 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 '函数名:GetCode '作用:提取网页编码 '参数:str-待查询字符串,regstr-正则表达式 Function GetCode(str) Dim Reg,serStr set Reg= new RegExp Reg.IgnoreCase = True Reg.Pattern ="1\s*
|
|