Dim HtmlTempText As String
Private Sub Command1_Click()
Me.WebBrowser1.Navigate Me.Text1.Text
'Form1.Show
' Me.WebBrowser1.SetFocus
End Sub
Private Sub Form_Load()
'Form1.Show
'Me.WebBrowser1.SetFocus
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
On Error Resume Next
WebBrowser1.SetFocus
Dim doc As Object
Set doc = WebBrowser1.Document
If InStr(doc.body.innerText, Text3.Text) > 0 Then
doc.All.Item("FontSize").focus
Dim objHtml As Object
Set objHtml = doc.body.createTextRange()
If Not IsNull(objHtml) Then
HtmlTempText = objHtml.htmlText
Text2.Text = HtmlTempText
End If
Dim tmp As String
tmp = "fasdfasdfsfd"
'Dim aa As Long
'aa = PostMessage(Me.WebBrowser1.hwnd, &H100, 9, 0)
SendKeys "{tab}"
SendKeys tmp
'SendKeys "{tab}"
' SendKeys "{tab}"
' 'doc.All.Item("Submit").focus
'SendKeys "{enter}"
Dim str As String
str = "asdf"
SendKeys "^{enter}"
End If
If InStr(doc.body.innerText, "fasdfasdfsfd") > 0 Then
doc.All.Item("FontSize").focus
tmp = "fasdfasdfsfd"
'Dim aa As Long
'aa = PostMessage(Me.WebBrowser1.hwnd, &H100, 9, 0)
SendKeys "{tab}"
SendKeys tmp
'SendKeys "{tab}"
' SendKeys "{tab}"
' 'doc.All.Item("Submit").focus
'SendKeys "{enter}"
SendKeys "^{enter}"
End If
If InStr(doc.body.innerText, "错误信息") > 0 Then
Me.WebBrowser1.Navigate Me.Text1.Text
End If
End Sub
上面的代码中有许多注释掉的语句,是我调试的时候注释掉的,你将该代码原封不动的拷到VB下就可以用了,注意Text1.Text的内容是你要灌水贴的网址如:
http://bbs.wwenglish.org/dispbbs.asp?boardID=73&ID=39431&page=1
在灌水之前,你要先登陆,取得灌水的权利。还有非常重要的一点是Text3.Text的内容是该帖子页面上典型文字,说白了就是该页面上一行或半行文字,以使程序确认该页面,比如帖子中的文字“考研翻译资料系列”之类的。 ==========不明白的地方有:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
这是一个什么控件? 注意Text1.Text的内容是你要灌水贴的网址如:
http://bbs.wwenglish.org/dispbbs.asp?boardID=73&ID=39431&page=1 这句要怎么改?我把text1.text改成了网站地址却不正确!