0

以前的研究

我已经阅读了 splinter 帮助文档并搜索了 Stack Overflow 并花了大约 4 个小时尝试各种想法,主要是结合使用 dir() 和 firefox 的“检查元素”功能。没有成功。

问题

我正在努力弄清楚如何在 Linkedin 中自动认可我的连接技能,将交互限制为尚未认可的技能。对人眼来说,此类技能以灰色十字表示,而不是蓝色十字,前提是该技能已经得到认可。

在此处输入图像描述

4

1 回答 1

0

你需要对给定技能.click()<a class="endorse-button" role="button" href="javascript:void(0)">元素。

您可以通过检查按钮元素(上面提到的)的父元素中是否存在“可背书”来过滤尚未背书的技能has class="endorse-item has-endorsements endorsable"。具体来说:<li class="endorse-item has-endorsements endorsable" data-endorsed-item-name="Molecular Biology">

字符串"endorsable"将未认可的技能与认可的技能区分开来,例如,已经认可的技能显示为<li class="endorse-item has-endorsements endorsed-by-viewer" data-endorsed-item-name="genetics">:你有字符串"endorsed-by-viewer"而不是"endorsable " 。

过滤所需的代码,然后点击可认可的技能是这样的:

##############################################################
# Searches for the "endorse skills" buttons and iteratively clicks them...
##############################################################

list_of_skills = browser.find_by_id("profile-skills")[0].find_by_css("li")

for skill in list_of_skills:

    if skill.has_class("endorse-item has-endorsements endorsable"):

        # ...this skill can be endorsed

        button_and_other = skill.find_by_css("div")[0].find_by_css("a") # there are two elements that match "a": [0] list of endorsers, [1] the endorse button

        for css in button_and_other:

            if css.has_class("endorse-button"): # ..if the element has the class: "endorse-button" we click it

                css.click()
    else:

        # ...this skill is already endorsed

        pass
于 2015-02-11T23:57:52.190 回答