Used a copy selector function.
So I usually try to figure out myself first how I could select the element and I end up with shorter
CSS selectors.
It sometimes is a little.
Easy to read, I think.
But you can also just use this.
But if I had to come up with like my own manual way of figuring out how to select this, you could go
and say, okay, it is inside the P element with the class attribute group.
So you can say.
And p dot attribute group.
So that is that element.
But then we need to go and say, okay, we also want the first span element.
And then you can use you can get some inspiration from the selector that Chrome tools gave you.
And you can see here it says span and then it says env child.
So that means the first child, which is a span from this parent element, then we can say.
Okay.
So let me show you the text first from this one.
That looks like this.
It gets all the elements here.
So all of these ones.
But we want just a first child.
So the first span child.
That means you can do something like this.
Span inf child.
And then you say the first child and then we just get this instead.
And then again, if I wanted to get just the bold element, we can try and do that so we can say, Just
give me the bold.
Then we can use the child selector again.
Which is this one and say B, and then we just get the compensation.
So that is, as you can see, a shorter CSS selector to use rather than this one.
But they both work.
So if you want to use this one, feel free to use it.
If it works, it works.
I just like to fiddle around with myself and see if I can get a smaller CSS selector usually.
So I'm going to go ahead and use my own CSS selector here.
Feel free to use the one from copy selector if you want to.
And then we're going to go and add it to our object inside the scrape job descriptions.
So in we can see here, we can say listings on the I index and say the compensation.
Is equal to compensation and I need to declare the variable first compensation.
And we can say const compensation equals my CSS selector.
This one.
Don't text.
And that should be it.
Now I'm going to do another console log just to check if I'm getting the right data.
And then we can say Node index.js and we can check out if we get the right data.
So now it's going through all the job descriptions and I can see the compensation is down here at the
end of the console log.
So competitive salaries depending on experience and so on.
So people that is how we get the compensation from all of these job descriptions.
It was probably the most complicated element to select so far in this section.
Because it didn't have any CS class in the element that we can just easily select like we've done before.
We had to go through a little child parent nest in here where we have to select first.
We selected the P element because that has a class.
And then we said, okay, give me the first child and then give me the child element.
That is a B element.
So a little more complicated.
But sometimes you have to do that and get through with it.
So in the next section, we're going to look at how to save this data.
We are now scraping onto a MongoDB database.
And yeah, that's going to be a lot of fun too.
And I'll see you in the next section.