Reputation: 131
from selenium import webdriver
from time import sleep
from selenium.common.exceptions import NoSuchAttributeException
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get('https://www.linkedin.com/jobs/search?locationId=sg%3A0&f_TP=1%2C2&orig=FCTD&trk=jobs_jserp_posted_one_week')
jobtitlebutton = driver.find_elements_by_class_name('job-title-link')
print(jobtitlebutton)
The output is a selenium webelement in the form of a list. I want to convert it into a string variable so that the list can contain all the jobtitles in text format. If I can get assistance in this it will be great. Thanks in advance.
Upvotes: 6
Views: 19795
Reputation: 52665
In case, if you need a list of links to each job:
job_list = []
jobtitlebuttons = driver.find_elements_by_class_name('job-title-link')
for job in jobtitlebuttons:
job_list.append(job.get_attribute('href'))
In case, if you want just a job titles list:
job_list = []
jobtitlebuttons = driver.find_elements_by_class_name('job-title-text')
for job in jobtitlebuttons:
job_list.append(job.text)
Upvotes: 8