请给段代码
解决方案 »
- VB向MYSQL 插入数据时问题.(一次插入多条记录)在线等.谢谢
- Vb如何读取pc后面并口(D型25pin)发送进来的字符?
- 求一超难SQL语句………………
- 一个超级搞的问题!!!(最后10分了)
- 看看我做的游戏吧,顺便拉拉选票
- 如何修改字符串里某一个字符
- 散分了!!!!新年快乐!!! VB中如何把水晶报表导入到EXCEL文件里
- 寻到以前注册的MJ,有8120分,高兴,特散!
- 大家开发数据库程序时多用什么控件?
- 在调用api函数时,有时会定义一些参数 如 Const TOKEN_ADJUST_PRIVILEGES = &H20,请问&h20的意义是什么,换成别的值可以吗
- 求救,在线等。
- 急急急,谁有抽奖程序,急需
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
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
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