0

Previous research

I haveve read the splinter help docs and searched Stack Overflow and spent about 4 hours trying various ideas, mainly playing with dir() in combination with firefox's "inspect element" feature. No success.

Question

I am struggling to figure out how I can automatically endorse skills of my connections in Linkedin, restricting the interaction to skills that are not yet endorsed. To the Human eye, such skills are presented with a grey cross as opposed to a blue cross had that skill already been endorsed.

enter image description here

hello_there_andy
  • 2,039
  • 2
  • 21
  • 51
  • 1
    Surely the trickier bit would be writing the code to determine whether or not you know if they're any good at that skill? – jonrsharpe Feb 11 '15 at 23:54

1 Answers1

0

You need to .click() on the <a class="endorse-button" role="button" href="javascript:void(0)"> element of a given skill.

You can filter the skills that are not yet endorsed by checking if there is "endorsable" in a parent element of the button element (mentioned above) has class="endorse-item has-endorsements endorsable". Specifically: <li class="endorse-item has-endorsements endorsable" data-endorsed-item-name="Molecular Biology">.

The string "endorsable" is what separates un-endorsed skills from endorsed ones, for example, already endorsed skills appear as: <li class="endorse-item has-endorsements endorsed-by-viewer" data-endorsed-item-name="genetics">; where instead of "endorsable" you have the string "endorsed-by-viewer".

The code required to filter, then click on endorsable skills is thus:

##############################################################
# 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
hello_there_andy
  • 2,039
  • 2
  • 21
  • 51