网页是 http://www.newrank.cn/public/info/search.html 这网页在里面搜索公众微信号,然后点击添加到选号车,这是我的目标。但好像我的代码htme.children(0).firstchild.children(1).firstchild.invokemember("click") 不行
Dim htme,htmaccount As System.Windows.Forms.HtmlElement
Dim web As System.Windows.Forms.WebBrowser = e.Form.Controls("WebBrowser1").BaseControl
Dim enc As String
web.Navigate("http://www.newrank.cn/public/info/search.html")
Do While web.ReadyState <> 4
messagebox.show("等待加载,有没有办法,不用这个messagebox来人工判断是否加载完成")
Application.DoEvents
Loop
htmaccount = web.Document.getelementbyid("txt_account")
If htmaccount IsNot Nothing Then
htmaccount.Innertext = "旅游" '填入搜索关键字
htme = web.Document.getelementbyid("btn_search") '找到搜索按钮
'messagebox.show("点击搜索目标")
htme.Invokemember("click") '自动点击搜索按钮
messagebox.show("等待搜索,有没有办法,不用这个messagebox来人工判断是否搜索完成")
htme = web.Document.getelementbyid("result_list") '找到网页结果栏
If htme.children.count = 0 Then
'messagebox.show( "没有找到该公众号" )
Else
'enc= htme.children(0).firstchild.firstchild.children(1).Innerhtml
enc= htme.children(0).firstchild.children(1).innerhtml
messagebox.show(enc)
If enc.Contains("已") Then
'messagebox.show("该公众号已经在库")
Else '点击添加到选号车按钮,添加该公众号到你的购物车,该按钮在鼠标没移动过去时候,是不会显示的
messagebox.show(enc,"正在添加"& htme.children(0).firstchild.children(1).firstchild.tagname)
htme.children(0).firstchild.focus() '此语句无效
htme.children(0).firstchild.children(1).firstchild.invokemember("click") '此语句无效 有没有办法直接执行 A href的script呢
End If
End If
End If