单击包含 VBS 中某个字符串的链接 [英] Clicking on a link that contains a certain string in VBS

查看:26
本文介绍了单击包含 VBS 中某个字符串的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行一个自动化的 vbs 脚本,该脚本可以点击页面上的链接.我有以下形式的东西:

const READYSTATE_COMPLETE = 4Set IE = CreateObject("INTERNETEXPLORER.APPLICATION")IE.Visible = 真IE.navigate ("http://mywebpage.com")

然后我如何让它点击该页面上没有 ID 但类似的链接

ClickMe!</a>

谢谢!

沿着线

Dim LinkHref昏暗LinkHref = "链接"对于每个 a 在 IE.Document.GetElementsByTagName("A")如果 LCase(a.GetAttribute("href")) = LCase(LinkHref) 那么a.点击Exit For ''# 在第一次点击后停止万一下一个

代替 LCase(…) = LCase(…),您还可以使用 StrComp(…, …, vbTextCompare)(参见 StrComp() 在 MSDN 上).

I'm trying to run an automated vbs script that clicks on a link on a page. I have things of the form:

Const READYSTATE_COMPLETE = 4  
Set IE = CreateObject("INTERNETEXPLORER.APPLICATION")  
IE.Visible = true  
IE.navigate ("http://mywebpage.com")

How do I then make it click on a link on that page that doesn't have an ID but is like

<a href="link">ClickMe!</a>

Thanks!

解决方案

Along the lines of

Dim LinkHref
Dim a

LinkHref = "link"

For Each a In IE.Document.GetElementsByTagName("A")
  If LCase(a.GetAttribute("href")) = LCase(LinkHref) Then
    a.Click
    Exit For  ''# to stop after the first hit
  End If
Next

Instead of LCase(…) = LCase(…) you could also use StrComp(…, …, vbTextCompare) (see StrComp() on the MSDN).

这篇关于单击包含 VBS 中某个字符串的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆