微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/vb/263346.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐