zoukankan      html  css  js  c++  java
  • VB获得迅雷资讯弹出网页的源代码

    迅雷资讯弹出网页采用UTF-8编码,需要编制自定义函数对XMLHTTP对象获得的源代码进行转换:
    1. Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As LongByVal dwFlags As LongByVal lpMultiByteStr As LongByVal cchMultiByte As LongByVal lpWideCharStr As LongByVal cchWideChar As LongAs Long
    2. Private Const CP_UTF8 = 65001
    3. Function Utf8ToUnicode(ByRef Utf() As ByteAs String
    4.     Dim lRet As Long
    5.     Dim lLength As Long
    6.     Dim lBufferSize As Long
    7.     lLength = UBound(Utf) - LBound(Utf) + 1
    8.     If lLength <= 0 Then Exit Function
    9.     lBufferSize = lLength * 2
    10.     Utf8ToUnicode = String$(lBufferSize, Chr(0))
    11.     lRet = MultiByteToWideChar(CP_UTF8, 0, VarPtr(Utf(0)), lLength, StrPtr(Utf8ToUnicode), lBufferSize)
    12.     If lRet <> 0 Then
    13.         Utf8ToUnicode = Left(Utf8ToUnicode, lRet)
    14.     End If
    15. End Function
    16. Function SourcecodeofXunleizixun(ByVal menuindex As LongAs String
    17.     Dim b() As Byte, indexurl(5) As String
    18.     If Not menuindex Like "[0-5]" Then Exit Function
    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.     With CreateObject("Msxml2.XMLHTTP")
    26.         .Open "GET", indexurl(menuindex), False
    27.         .Send
    28.         b = .ResponseBody
    29.     End With
    30.     SourcecodeofXunleizixun = Utf8ToUnicode(b)
    31. End Function
    32. Sub Getxunlei()
    33.     Debug.Print SourcecodeofXunleizixun(1)    '娱乐资讯
    34. End Sub
  • 相关阅读:
    Spring+Mybatis整合
    Spring入门之生命周期
    异常处理
    淘淘商城第一天
    Maven的Setting配置
    mysql下载
    整合mybatis的CRUD4
    整合mybatis的CRUD3
    整合mybatis的CRUD2
    整合mybatis的CRUD
  • 原文地址:https://www.cnblogs.com/fengju/p/6336229.html
Copyright © 2011-2022 走看看