0

I have this site https://jobs.ubs.com/TGnewUI/Search/home/HomeWithPreLoad?partnerid=25008&siteid=5012&PageType=searchResults&SearchType=linkquery&LinkID=6017#keyWordSearch=&locationSearch=

I want to scrape the link for each job role, the HTML source for one of the roles is:

<a id="Job_1" href="https://jobs.ubs.com/TGnewUI/Search/home/HomeWithPreLoad?partnerid=25008&amp;siteid=5012&amp;PageType=JobDetails&amp;jobid=223876" ng-class="oQ.ClassName" class="jobProperty jobtitle" ng-click="handlers.jobClick($event, this)" ng-bind-html="$root.utils.htmlEncode(oQ.Value)">Technology Delivery Lead (IB Technology)</a>

I have tried this:

job_link = driver.find_elements_by_css_selector(".jobProperty.jobtitle ['href']")


for job_link in job_link:
    job_link = job_link.text
    print(job_link)

But it simply returns nothing, can someone kindly help

4
  • 1
    Try removing the space between jobtitle and ['href'] Commented Jan 16, 2021 at 23:03
  • Seeing this error selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: An invalid or illegal selector was specified Commented Jan 16, 2021 at 23:05
  • Sorry, yes, remove the quotes around href Commented Jan 16, 2021 at 23:08
  • Might be worth taking a look at beautiful soup Commented Jan 16, 2021 at 23:12

1 Answer 1

1

Why not just print out it's href tag by get_attribute.

job_link = driver.find_elements_by_css_selector(".jobProperty.jobtitle")

for job_link in job_link:
    print(job_link.get_attribute('href'))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.