以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  【已解决】[求助]网页自动填写  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=132418)

--  作者:zto001
--  发布时间:2019/3/21 15:24:00
--  【已解决】[求助]网页自动填写
通过ID写入
Dim web As System.Windows.Forms.WebBrowser= e.Form.Controls("WebBrowser1").baseControl

 web.Document.GetElementById("kw").SetAttribute("Value", e.Form.Controls("TextBox1").Text)

这种会
,如果是复杂的呢?比如这个网页。下载文件,我需要在受理人框内输入“受理人”,处理结果框内输入“结果”。怎么写呢?
[此贴子已经被作者于2019/3/21 22:16:56编辑过]

--  作者:有点甜
--  发布时间:2019/3/21 16:00:00
--  

找到对应的元素,如记录为 abc

 

给abc赋值,如 abc.SetAttribute("Value", "123")


--  作者:zto001
--  发布时间:2019/3/21 16:54:00
--  
弱弱的问句,取元素怎么取?
--  作者:zto001
--  发布时间:2019/3/21 17:07:00
--  
根据前面模拟点击按钮跟获取网页信息试了下,还是不会
--  作者:有点甜
--  发布时间:2019/3/21 17:09:00
--  
以下是引用zto001在2019/3/21 17:07:00的发言:
根据前面模拟点击按钮跟获取网页信息试了下,还是不会

 

看你之前发的帖子,读取表格内容、获取保存按钮,都是查找元素。

 

 


--  作者:zto001
--  发布时间:2019/3/21 17:37:00
--  
Dim web As System.Windows.Forms.WebBrowser = e.Form.Controls("WebBrowser3").Basecontrol
Do Until web.ReadyState = 4
    Application.DoEvents
Loop
msgbox("0")

Dim inputs = web.Document.GetElementsByTagName("div")
For Each Input As object In Inputs
    If Input.GetAttribute("class") = "z_value z_handleResult"
msgbox("1")
        Input.SetAttribute("Value", "123")
msgbox("2")
    End If
Next

1/2都没执行
[此贴子已经被作者于2019/3/21 17:37:51编辑过]

--  作者:有点甜
--  发布时间:2019/3/21 18:00:00
--  
Dim web As System.Windows.Forms.WebBrowser = e.Form.Controls("WebBrowser3").Basecontrol
Do Until web.ReadyState = 4
    Application.DoEvents
Loop
msgbox("0")

Dim inputs = web.Document.GetElementsByTagName("input")
For Each Input As object In Inputs
msgbox(input.innerHtml)
    If Input.GetAttribute("classname") = "z_value z_handleResult"
msgbox("1")
        Input.SetAttribute("Value", "123")
msgbox("2")
    End If
Next

--  作者:zto001
--  发布时间:2019/3/21 22:00:00
--  
Dim web As System.Windows.Forms.WebBrowser = e.Form.Controls("WebBrowser1").Basecontrol
Do Until web.ReadyState = 4
    Application.DoEvents
Loop
Dim inputs = web.Document.GetElementsByTagName("textarea")
For Each Input As object In Inputs
    If Input.GetAttribute("classname") = "z_value z_handleResult"
        Input.SetAttribute("Value", "处理结果")
    End If
Next

Dim inputs1 = web.Document.GetElementsByTagName("input")
For Each Input1 As object In Inputs1
    If Input1.GetAttribute("classname") = "z_value z_website"
        Input1.SetAttribute("Value", "对方网点")
    End If
    If Input1.GetAttribute("classname") = "z_value z_tell"
        Input1.SetAttribute("Value", "对方电话")
    End If
    If Input1.GetAttribute("classname") = "z_value z_accepter"
        Input1.SetAttribute("Value", "对方受理人")
    End If
Next

--  作者:zto001
--  发布时间:2019/3/21 22:04:00
--  
原来这个是用来取元素,这三种不同结果就是一种方法啊