• 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
  • 相关阅读:
    【NOI2015】品酒大会 SAM
    4566: [Haoi2016]找相同字符 SAM
    3709: [PA2014]Bohater 贪心
    1925: [Sdoi2010]地精部落 dp, 抖动子序列
    4205: 卡牌配对 最大流+建图技巧
    留言板
    self-introduction
    最近比赛
    STOI补番队胡策
    BZOJ 3503: [Cqoi2014]和谐矩阵( 高斯消元 )
  • 原文地址:https://www.cnblogs.com/fengju/p/6336229.html
Copyright © 2020-2023  润新知