6
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.

1
  • Do you need list of links or list of jobs (e.g. "Datacenter Technician", "Test Manager")? Commented Oct 13, 2016 at 4:43

1 Answer 1

8

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)
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks alot it did helped me alot.
I also would want to know how I can click each of the job title and extract the job description for which the class name is 'content'.
I guess you should loop through job_list of links and do something like description = "/n".join([i.text for i in driver.find_elements_by_xpath('//div[@class="content"]//ul/li')])
Thanks alot. It surely helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.