迅雷资讯弹出网页采用UTF-8编码,需要编制自定义函数对XMLHTTP对象获得的源代码进行转换:
- PrivateDeclareFunctionMultiByteToWideCharLib"kernel32"(ByValCodePageAsLong,ByValdwFlagsAsLong,ByVallpMultiByteStrAsLong,ByValcchMultiByteAsLong,ByVallpWideCharStrAsLong,ByValcchWideCharAsLong)AsLong
- PrivateConstCP_UTF8=65001
- FunctionUtf8ToUnicode(ByRefUtf()AsByte)AsString
- DimlRetAsLong
- DimlLengthAsLong
- DimlBufferSizeAsLong
- lLength=UBound(Utf)-LBound(Utf)+1
- IflLength<=0ThenExitFunction
- lBufferSize=lLength*2
- Utf8ToUnicode=String$(lBufferSize,Chr(0))
- lRet=MultiByteToWideChar(CP_UTF8,VarPtr(Utf(0)),lLength,StrPtr(Utf8ToUnicode),lBufferSize)
- IflRet<>0Then
- Utf8ToUnicode=Left(Utf8ToUnicode,lRet)
- EndIf
- EndFunction
- FunctionSourcecodeofXunleizixun(ByValmenuindexAsLong)AsString
- Dimb()AsByte,indexurl(5)AsString
- IfNotmenuindexLike"[0-5]"ThenExitFunction
- indexurl(0)="http://recommend.xunlei.com/desknews_v2_game.html"
- indexurl(1)="http://recommend.xunlei.com/desknews_v2_ent.html"
- indexurl(2)="http://biz5c.sandai.net/desktopnews/iframe/hot_14.htm"
- indexurl(3)="http://www.eachnet.com/landing/xunlei08_3.html"
- indexurl(4)="http://biz5c.sandai.net/desktopnews/iframe/hot_2.htm"
- indexurl(5)="http://biz5c.sandai.net/desktopnews/iframe/hot_3.htm"
- WithCreateObject("Msxml2.XMLHTTP")
- .Open"GET",indexurl(menuindex),False
- .Send
- b=.ResponseBody
- EndWith
- SourcecodeofXunleizixun=Utf8ToUnicode(b)
- EndFunction
- SubGetxunlei()
- Debug.PrintSourcecodeofXunleizixun(1)
- EndSub
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|