前端之家收集整理的这篇文章主要介绍了
VB获得迅雷资讯弹出网页的源代码,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
迅雷资讯弹出网页采用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
原文链接:https://www.f2er.com/vb/263346.html