Image what i want to download.
图片是我朋友的LinkedIn个人资料页面 我想点击许多用户的save-as-pdf选项。
可以使用python代码下载吗?对于不同的用户? 或者可以使用任何其他语言下载吗?
答案 0 :(得分:0)
是的,您可以使用适用于每个配置文件的python来自动执行此操作,因此您不必担心id的更改
import time
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
login = "Email address goes here"
password = "Type your password here"
#start browser session
chromedriver = "/home/romtein/chromedriver" #change this to your selenium driver
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
#open linkedin in automated browser
driver.get("https://www.linkedin.com/")
time.sleep(1)
#logs you into Linkedin
driver.find_element_by_id("login-email").send_keys(str(login))
password = driver.find_element_by_id("login-password").send_keys(str(password))
driver.find_element_by_id("login-submit").click()
print("successfully logged in")
#navigates to your connections
time.sleep(1)
driver.get("https://www.linkedin.com/mynetwork/invite-connect/connections/")
time.sleep(1)
#opens a new tab of your top contact
ActionChains(driver).key_down(Keys.CONTROL).send_keys('t').perform()
contact_page_open = driver.find_element_by_class_name("mn-connection-card__name").click()
time.sleep(2)
#switch to new tab
driver.switch_to_window(driver.window_handles[1])
time.sleep(1)
# ActionChains(driver).key_up(Keys.CONTROL).perform()
#click the "more" button
driver.find_element_by_class_name("pv-s-profile-actions__overflow").click()
time.sleep(1)
#saves profile to pdf
driver.find_element_by_class_name("pv-s-profile-actions pv-s-profile-actions--save-to-pdf").click()
time.sleep(1)
如果您有任何疑问,请告诉我