单击使用硒的LinkedIn按钮(python) [英] Clicking a LinkedIn button using selenium (python)

查看:69
本文介绍了单击使用硒的LinkedIn按钮(python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的小白花了很多时间试图在LinkedIn上单击一个Web元素,但没有成功.从这里开始是我正在处理的源代码:

noob here having a heck of time trying to click on a webelement within LinkedIn with no success. To begin here is the source code I'm dealing with:

这是我的登录名

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import urllib, os, urllib.request
import time

driver = webdriver.Safari()

usrName = 'your_email'
pssWrd = "your_password"

driver.maximize_window()
driver.get("https://www.linkedin.com/uas/login?")

driver.find_element_by_name('session_key').send_keys(usrName)
driver.find_element_by_class_name('password').send_keys(pssWrd)
driver.find_element_by_name('signin').click()

time.sleep(15)
driver.get("https://www.linkedin.com/search/results/people/facetNetwork=%5B%22S%22%5D&keywords=software%20engineers&origin=FACETED_SEARCH")

这是我要查找的块.

<button aria-label="Connect with LJ Wilson" class="search-result__actions--primary button-secondary-medium m5" data-ember-action="" data-ember-action-5373="5373" data-is-animating-click="true">
  Connect
</button>

我可以登录并导航到该页面(在您设置了linkIn的睡眠以加载通过防火墙之后),但是我已经做了所有尝试尝试单击该按钮的操作,但均未成功.

I can login and and navigate to the page just fine (after you set a sleep for linkedIn to load past a firewall), but I have done everything to try to click on the button with no success.

我尝试过:

driver.find_element_by_xpath("//button[@class='search-result__actions--primary button-secondary-medium m5']"[1]).click()

driver.find_element_by_xpath("//button[contains(text()="Connect])).click()

什么都没有.任何帮助将不胜感激.我一直无法点击LinkedIn按钮或元素,因为它在2016年这个时候改变了它的平台.

nothing.... any help would be much appreciated. I haven't been able to click on LinkedIn buttons or elements since it changed it's platform around this time in 2016.

这些是我遇到的3个错误:

These are the 3 errors I'm getting:

  1. 元素命令无法完成,因为该元素在页面上不可见.
  2. 使用给定的搜索参数无法在页面上找到元素.
  3. 未知的服务器端错误.

谢谢, 克里斯

推荐答案

这条线终于完成了工作……只是提出了另一个(不同的)问题,但是仍然取得了进展.

This was the line that finally got the job done... just brings up another (different) issue, but progress none the less.

driver.execute_script("document.getElementsByClassName('search-result__actions--primary button-secondary-medium m5')[1].click();")

这篇关于单击使用硒的LinkedIn按钮(python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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