Okay, one, we got the job titles from all the different jobs on this page.
Now, so far so good.
But we also need to get the job description URLs.
So remember that we wanted to get the URLs here.
So when you click on the job listing, you get to a page.
So this is the URLs we want to get for each of the job listings as well.
So how do we do that?
How can we select the job listing or the job listing URL?
Well, it's quite simple.
Again, just like when we are trying to find a title, we go into the Chrome developer tools.
So press F12.
And then we are going to use the inspect tool again.
So I'm going to click on the inspect tool here, and then I'm going to click on the element that I think
has the data that I want to get.
In this case, it's the link to the job description.
So I click on that and then again we can see the same element that we had before, which has the title
up here.
Let me just bring that down a little bit so you can see better.
So we can see the title here.
We got that before.
Remember, it's the same element again.
It is this a element because it's a link.
And so the text inside this element is the title.
We already got that from this result title class that we selected before.
Remember this one?
We did an each over the result title elements.
But now we need to get a different attribute.
We need to get the h href attribute instead of just the text content.
So before we got the text content here using the query jQuery or cherry selector where we say dot text.
And that's going to get us the content in here inside the element.
But now we want to get the attribute.
So how do you select the attribute?
It's really simple.
You just use the dot attr method and then you put in a string containing the attribute you want to get.
So if I put in the string of data ID, I'm going to get back the attribute value of this data ID, or
if I put in href, I'm going to get back the value of href attribute.
So let me show you inside the console first inside this Chrome developer console how we can select all
of the job description URLs.
So we go ahead and use the famous dollar sign first and then put in the selector.
And remember again, that is the same CSS selector we can use result title.
We could also use this one.
The I think it stands for header link, but let's just use the same one we used before.
So remember the dot in front because it's because it's a CSS class.
So result title.
And then we can do a dot each loop for each of these listings we have on the page.
So each and again, just like before, the first argument we get back from this, each loop is the index
and the second one is the element itself.
So index element.
And then we do an arrow function.
And then we can do a console log just to see if we're getting the right value so we can say console
log and then we can use, again the jQuery selector to select the element or the elements attributes
properties that we want to get.
So dollar sign and then we pass in the current element in the loop and we say dot ECR and in here we
can put in well I can put in data ID or I can put in RF So RF is where the link is inside of an element
in HTML.
And then we close it with the parentheses and let's try and see.
So if I scroll up now, I can see all of the different links for the job descriptions.
And up here is the code that we used.
Now I can just copy and paste that into NodeJS just like before, and we should be able to get the job
descriptions as well inside of NodeJS.
So I'm going to copy this.
Let's see.
Copy that and then paste it inside the NodeJS section here.
And.
Now let's try and run it and see if we get all of the job URLs just for fun.
Now it's going to open up the chromium browser and looks like the page has loaded now and then I can
see all of the different job description URLs inside of my console and if I scroll up I can also see
all of the different titles that we're also printing inside here.
So cooling off, that's how we can select the job description URLs.
In this case, we're using the Dot attribute method to select an attribute on the HTML element.
So, so, so, so far so good.
But we we are missing something because as you can see, we're just printing out different strings.
But as I showed before in another section, we wanted to have sort of this data structure where we have
different objects that contains different properties so that we later have it sort of in one place and
we can put it up in MongoDB.
So we can say that one object has a title, a URL.
So it all fits together for one object.
Right now, it's kind of hard to know if what you're URL fits for what title because we're doing a each
loop for each element.
Maybe one of the elements has an error and suddenly it makes a skip and you don't know which title fits
what URL.
But anyway, in the next section, I'm going to show you how we are going to solve this problem of either
combining the arrays or making it just into one array at the output and how to make an object as the
output.
So see you in the next section where I'm going to show you this.