I am trying to select the job posting titles and the href for the job postings. Then return response. Can you tell me what I am doing wrong here?
Here is my last attempt:
function ExecuteScript() {
let response = '';
document.querySelectorAll('h2[data-bind="text: job.title"]').forEach((element, i) => {
response += element.innerHTML + '\\t' + location.host + element.getAttribute('href') + '\\n';
});
return response;
}
First of all, inspect how page structure looks like: each list element (job post) is list item (li) with full-size link (a) inside it. Also each item contain h2 header that represent post title:
li -> a
-> div -> h2
So to grab both title and link you can iterate through list items and search for target children elements:
Array.from(document.querySelectorAll('li.job-tile')).map(element => ({
title: element.querySelector('h2.job-tile__title').innerText,
link: element.querySelector('a.job-tile__show').href
}))
Where
li.job-tile - list item, post tile actually
h2.job-tile__title - header, post title
a.job-tile__show - link, post page URL
This snippet will return array of objects with title & links like this:
[
{
title: 'Application Engineer (Custom Solutions)',
link: 'https://epyz.fa.us2.oraclecloud.com/hcmUI/Candidat…nLevel=city&mode=location&radius=25&radiusUnit=MI'
},
{
title: 'Intern - Custom Solutions (Information Systems)',
link: 'https://epyz.fa.us2.oraclecloud.com/hcmUI/Candidat…nLevel=city&mode=location&radius=25&radiusUnit=MI'
},
...
]
Also should be noticed that feed you provided contains paggination (as infinite scroll) so grabbing methods like this one will parse only visible posts (loaded), not all of them.