请给段代码

解决方案 »

  1.   

    不是,是放个image控件,然后放个webbrowser,放个commandbutton,点command1,image上面就显示那页上面的验证码
      

  2.   

    以前这段代码是好使的,现在却不能用了'窗体上添加2个CommandButton,1个Image,1个WebBrowser Private   Sub   Command1_Click() 
    WebBrowser1.Navigate2   "http://post.baidu.com/f?kz=207893930 " 
    End   Sub Private   Sub   Command2_Click() 
    'CommandButton按两次,Image控件讲显示验证码图片 
            Dim   CtrlRange,   x,   k   As   Boolean 
            
            For   Each   x   In   WebBrowser1.Document.All 
                    If   x.tagName   =   "TEXTAREA "   And   k   =   False   Then 
                            If   x.Name   =   "co "   Then 
                                    x.focus 
                                    k   =   True 
                            End   If 
                    End   If 
                    If   x.tagName   =   "IMG "   And   k   Then 
                            If   InStr(1,   x.src,   "post.baidu.com/cgi-bin/genimg ")   >   0   Then 
                                    Set   CtrlRange   =   WebBrowser1.Document.body.createControlRange() 
                                    CtrlRange.Add   (x) 
                                    CtrlRange.execCommand   ( "Copy ") 
                                    Image1.Picture   =   Clipboard.GetData 
                            End   If 
                    End   If 
            Next 
    End   Sub 
      

  3.   

    不是识别验证,而是在image1里面显示当前页面的验证图片
      

  4.   

    或者是这样,怎样获取webbrowser1里已经打开的页面的源代码?
      

  5.   

    可以用代码执行copy命令把图片复制到剪贴板
      

  6.   

    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
    Private Const IF_FROM_CACHE = &H1000000
    Private Const IF_MAKE_PERSISTENT = &H2000000
    Private Const IF_NO_CACHE_WRITE = &H4000000
    Private Const BUFFER_LEN = 512'Get   html   source
    Public Function GetUrlSource(sUrl As String) As String
        Dim sBuffer As String * BUFFER_LEN, iResult As Integer, sData As String
        Dim hInternet As Long, hSession As Long, lReturn As Long    'get   the   handle   of   the   current   internet   connection
        hSession = InternetOpen("VBhtml", 1, vbNullString, vbNullString, 0)
        'get   the   handle   of   the   url
        If hSession Then hInternet = InternetOpenUrl(hSession, sUrl, vbNullString, 0, IF_NO_CACHE_WRITE, 0)
        'if   we   have   the   handle,   then   start   reading   the   web   page
        If hInternet Then
            'get   the   first   chunk   &   buffer   it.
            iResult = InternetReadFile(hInternet, sBuffer, BUFFER_LEN, lReturn)
            sData = sBuffer
            'if   there's   more   data   then   keep   reading   it   into   the   buffer
            Do While lReturn <> 0
                iResult = InternetReadFile(hInternet, sBuffer, BUFFER_LEN, lReturn)
                sData = sData & Mid(sBuffer, 1, lReturn)
            Loop
        End If
        InternetCloseHandle hInternet
        InternetCloseHandle hSession
        GetUrlSource = sData
    End FunctionPrivate Sub Command1_Click()
        RichTextBox1.Text = GetUrlSource("http://www.163.com")
    End Sub
      

  7.   

    你哪原来的代码略一修改不就行了
    Private Sub WebBrowser1_DownloadComplete()
        Dim CtrlRange , x
        Dim k As Boolean
        
        For Each x In WebBrowser1.Document.All
                If x.tagName = "TEXTAREA" And k = False Then
                        If x.Name = "co" Then
                                x.focus
                                k = True
                        End If
                End If
                If x.tagName = "IMG" And k Then
                        If x.Id = "y_img" Then
                                Set CtrlRange = WebBrowser1.Document.body.createControlRange()
                                CtrlRange.Add (x)
                                CtrlRange.execCommand ("Copy")
                                Image1.Picture = Clipboard.GetData
                        End If
                End If
        NextEnd Sub
    Private Sub Command1_Click()
    WebBrowser1.Navigate2 Text1.Text
    End Sub
      

  8.   

    在text1中输入百度贴吧的贴子url