VB Wininet 获取网站网页Html源码,VB Wininet 获取网站Html源码,VB Wininet 获取网页Html源码,VB Wininet 获取网页Html,VB Wininet 获取网页源码,VB Wininet 获取Html源码,VB Wininet 网站网页Html源码,VB Wininet 网站Html源码,VB Wininet 网页Html源码,VB Wininet 网页Html,VB Wininet 网页源码,VB Wininet Html源码,VB 获取网站网页Html源码,VB 获取网站Html源码,VB 获取网页Html源码,VB 获取网页Html,VB 获取网页源码,VB 获取Html源码,VB Html源码,VB 网页源码,VB 源码,wininet.dll,InternetOpen,InternetOpenUrl,InternetReadFile,InternetCloseHandle,INTERNET_FLAG_NO_CACHE_WRITE = &H4000000,InternetOpen("VBTagEdit", 1, vbNullString, vbNullString, 0),InternetOpenUrl(LgSession, U, vbNullString, 0, INTERNET_FLAG_NO_CACHE_WRITE, 0),InternetReadFile(LgInternet, StBuf, 1024, LgRet),InternetCloseHandle(LgInternet)。

VB Wininet 获取网站网页Html源码:

Option Explicit

'获取网页源码部分
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal sUrl As String, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer '获取网页源码部分

Public Function GetInfo(U As String) As String                                  '获取网页源码 GetInfo("http://www.baidu.com/")
    On Error GoTo Over
    Dim LgInternet As Long, LgSession As Long, StBuf As String * 1024, InRes As Integer, LgRet As Long, StTotal As String
    Const INTERNET_FLAG_NO_CACHE_WRITE = &H4000000
    StTotal = vbNullString
    LgSession = InternetOpen("VBTagEdit", 1, vbNullString, vbNullString, 0)
    If LgSession Then
        LgInternet = InternetOpenUrl(LgSession, U, vbNullString, 0, INTERNET_FLAG_NO_CACHE_WRITE, 0)
        If LgInternet Then
            Do
                InRes = InternetReadFile(LgInternet, StBuf, 1024, LgRet)
                StTotal = StTotal & Mid$(StBuf, 1, LgRet)
            Loop While (LgRet <> 0)
        End If
        InRes = InternetCloseHandle(LgInternet)
    End If
    GetInfo = StTotal
    Exit Function
Over:
    GetInfo = ""
End Function

GetInfo("http://www.baidu.com/") '获取网页源码