以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]如何模拟点击网页中的标签 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=141847) |
-- 作者:JN_LC -- 发布时间:2019/10/12 12:37:00 -- [求助]如何模拟点击网页中的标签 网页中有个“查看”的按钮,html的代码如下: <img align="absmiddle" style="cursor:pointer;" src="/images/info/tubiao/cx01.gif" border="0"> 里面没有name,也没有id.请问怎么用代码模拟点击? 上面的代码里,还有个onclick=,点发表话题时,会消失。
[此贴子已经被作者于2019/10/12 13:10:33编辑过]
|
-- 作者:有点蓝 -- 发布时间:2019/10/12 13:46:00 -- 只能使用遍历的方式了,使用GetElementsByTagName遍历img标签 Dim imgs As System.Windows.Forms.HtmlElementCollection = web.Document.GetElementsByTagName("img") for each ig as object in imgs if ig.GetAttribute("src") = "/images/info/tubiao/cx01.gif" \'通过某个属性判断是否需要点击的img标签 ig.InvokeMember("click") end if next
|