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

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...