What I want to do is save the resume provided by LinkedIn (save as pdf option) as in this figure. I use Google Chrome as my browser. I found this answer. but I failed to reproduce the answer for the 2022 LinkedIn UI version. How to reproduce this answer for 2022?
This is what I already Tried.
import time
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
login = "##############"
password = "############"
class Linkedin:
def __init__(self,username,password):
self.username=username
self.password=password
options = webdriver.ChromeOptions()
options.add_argument('headless')
options.add_experimental_option('excludeSwitches', ['enable-logging'])
self.bot=webdriver.Chrome('chromedriver', options=options)
def login(self):
bot=self.bot
bot.get("https://www.linkedin.com/uas/login")
time.sleep(3)
email=bot.find_element(By.ID,"username")
email.send_keys(self.username)
password=bot.find_element(By.ID,"password")
password.send_keys(self.password)
time.sleep(3)
password.send_keys(Keys.RETURN)
load=Linkedin(login,password)
load.login()
print("Successfully logged in")
#navigates to your profile
time.sleep(1)
load.bot.get("https://www.linkedin.com/in/isuru-alagiyawanna-536881121/")
time.sleep(1)
#clicks on the "more" button on Linkedin
load.bot.find_element(By.CLASS_NAME,"pv-top-card-section__inline-overflow-button").click()
This returns the NoSuchElementException Error.
CodePudding user response:
I use the following code to tried, it worked well
from clicknium import clicknium as cc
if not cc.chrome.extension.is_installed():
cc.chrome.extension.install_or_update()
tab = cc.chrome.open("https://www.linkedin.com/in/isuru-alagiyawanna-536881121/")
#elem = tab.find_element_by_xpath('//span[text()="More"]').click()
#tab.find_element_by_xpath('//div[@aria-hidden="false"]//span[text()="Save to PDF"]').click()
tab.find_element_by_xpath('//div[@aria-hidden="true"]//span[text()="Save to PDF"]').click()