Autoit - 在网页中搜索 URL 并点击它

Autoit - searching for a URL in a web page and click on it

我想知道如何点击与特定模式匹配的 URL。 例如:

#include <IE.au3>
#include <MsgBoxConstants.au3>

local $pattern = "/123/"
Local $oIE = _IECreate("www.example.com",0,1,1,1)
Local $oLinks = _IELinkGetCollection($oIE)

For $oLink In $oLinks

    If StringInStr($oLink, $pattern)  Then
        _IEAction($oLink, "click")
        sleep(700)
        _IEQuit($oIE)
        ExitLoop
    EndIf
Next

基本上我需要实现的是, 如果 $oLinks 中的 $oLink 包含 $pattern - 点击它。 上面的程序,由于某种原因,不能运行。

有什么建议吗?

谢谢

我不确定您是否可以对该对象使用 StringInStr

尝试使用:

StringInStr($oLink.href, $pattern)

相反。

你得到这段代码的链接了吗?

#include <Array.au3>
#include <Inet.au3>
local $pattern = "/123/"
$source = _INetGetSource('https://www.nytimes.com/')
$links = StringRegExp($source, 'href="(http.*?)"', 3)
_ArrayDisplay($links)

然后你只需要调整你的 For Next 循环并在每个链接上使用 StringInStr[$i]