1

我是脚本的新手,我正在编写一些东西,这些东西会让我登录到我的 facebook,然后去朋友墙并为他们发布一些东西。我被困在最后一部分。我无法获取“发布”按钮的对象名称。

有人可以帮我完成我的代码吗?

#include <IE.au3>

Call("fcb")

Func fcb()
Global $oIE = _IECreate("https://www.facebook.com/")

local $userName = _IEGetObjByName($oIE, "email")
local $passWord = _IEGetObjByName($oIE, "pass")
local $log = _IEGetObjById($oIE, "loginbutton")

_IEFormElementSetValue($userName,"myemail")
_IEFormElementSetValue($passWord,"mypasscode")

_IEAction($log,"click")

EndFunc

Call("fcb2")

Func fcb2()
Global $oIE = _IECreate(https://www.facebook.com/myfriednspage)
local $box = _IEGetObjById($oIE, "u_0_1a")
_IEAction($box,"click")
local $typeInWall = _IEGetObjById($oIE, "u_0_1a")
_IEFormElementSetValue($typeInWall,"hi ugly")
local $toSubmit = _IEGetObjectType($oIE, "submit")
_IEAction($toSubmit,"click")

EndFunc

这是我在“发布”按钮上单击检查元素时得到的代码:

<button class="_42ft _4jy0 _11b _4jy1 selected _51sy"
type="submit" value="1" data-ft="{"tn":"+{"}">Post</button>

我认为这是我遇到问题的线路:

"local $toSubmit = _IEGetObjectType($oIE, "submit")"
4

1 回答 1

2

为此,您需要创建自己的功能。

您需要列出所有按钮,然后搜索一个以“发布”作为内文的按钮。

像这样的东西:

$oPostBtn = _IEGetObjByText($oIE, "button", "Post")

$oPostBtn.click

Func _IEGetObjByText($oObj, $tag, $text)

    Local $oButtons = _IETagNameGetCollection($oObj, $tag)

    For $oButton In $oButtons
        if $oButton.innertext == $text Then Return SetError(0, 0, $oButton)
    Next

    Return SetError(1, 0, False)

EndFunc

请注意,页面上可能有多个“发布”按钮。最安全的方法是将搜索范围缩小到表单对象。您可以找到所需的表单并将该对象用作 IEGetObjByText 中的第一个参数。

于 2015-06-10T12:41:35.513 回答