VB获得迅雷资讯弹出网页的源代码

前端之家收集整理的这篇文章主要介绍了VB获得迅雷资讯弹出网页的源代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
迅雷资讯弹出网页采用UTF-8编码,需要编制自定义函数对XMLHTTP对象获得的源代码进行转换:
  1. PrivateDeclareFunctionMultiByteToWideCharLib"kernel32"(ByValCodePageAsLong,ByValdwFlagsAsLong,ByVallpMultiByteStrAsLong,ByValcchMultiByteAsLong,ByVallpWideCharStrAsLong,ByValcchWideCharAsLong)AsLong
  2. PrivateConstCP_UTF8=65001
  3. FunctionUtf8ToUnicode(ByRefUtf()AsByte)AsString
  4. DimlRetAsLong
  5. DimlLengthAsLong
  6. DimlBufferSizeAsLong
  7. lLength=UBound(Utf)-LBound(Utf)+1
  8. IflLength<=0ThenExitFunction
  9. lBufferSize=lLength*2
  10. Utf8ToUnicode=String$(lBufferSize,Chr(0))
  11. lRet=MultiByteToWideChar(CP_UTF8,VarPtr(Utf(0)),lLength,StrPtr(Utf8ToUnicode),lBufferSize)
  12. IflRet<>0Then
  13. Utf8ToUnicode=Left(Utf8ToUnicode,lRet)
  14. EndIf
  15. EndFunction
  16. FunctionSourcecodeofXunleizixun(ByValmenuindexAsLong)AsString
  17. Dimb()AsByte,indexurl(5)AsString
  18. IfNotmenuindexLike"[0-5]"ThenExitFunction
  19. indexurl(0)="http://recommend.xunlei.com/desknews_v2_game.html"'0---游戏
  20. indexurl(1)="http://recommend.xunlei.com/desknews_v2_ent.html"'1---娱乐
  21. indexurl(2)="http://biz5c.sandai.net/desktopnews/iframe/hot_14.htm"'2---婚恋
  22. indexurl(3)="http://www.eachnet.com/landing/xunlei08_3.html"'3---网购
  23. indexurl(4)="http://biz5c.sandai.net/desktopnews/iframe/hot_2.htm"'4---财经
  24. indexurl(5)="http://biz5c.sandai.net/desktopnews/iframe/hot_3.htm"'5---IT
  25. WithCreateObject("Msxml2.XMLHTTP")
  26. .Open"GET",indexurl(menuindex),False
  27. .Send
  28. b=.ResponseBody
  29. EndWith
  30. SourcecodeofXunleizixun=Utf8ToUnicode(b)
  31. EndFunction
  32. SubGetxunlei()
  33. Debug.PrintSourcecodeofXunleizixun(1)'娱乐资讯
  34. EndSub
原文链接:https://www.f2er.com/vb/263346.html

猜你在找的VB相关文章