Okay, so now we got the job title and the URL inside of this nice array of objects.
Now we just need to add more properties to it.
In the next one we need to add is the date that the job was posted.
So how can we do that?
Well, let's get on to it and I'll show you.
First of all, let's open up chrome developer tools just like we've done before.
So F12.
And then I'm going to use the inspect element tool again.
So it's pretty much the same procedure as before.
And then I click on the date that I want to scrape.
So I click on this one and then I see what element that we can scrape the data from.
We can see here that it is a HTML time element and it has a class with the result date and a date time
attribute.
Now I want the data I'm scraping to be as accurate as possible.
So instead of just using the text content with August 1st, we're going to use the date time attribute
and create a JavaScript date object from that.
Because it also contains the exact time the job was posted.
But there is one issue or thing we need to watch out for.
Before we were iterating through each of the result title and we made it into one loop here.
But now this time class or time element has the class of result date.
So either we need to make two loops and then we have this problem that maybe some data is corrupted
and we're not going to have correct data.
But how can we make it inside one loop and just go through each of these rows here?
Well, we can see here that there's a parent element called result info.
The P element here.
And that's each row, basically, and that contains both the time class and the title and URL.
So we can use this to select child elements from this parent element.
And then we're sure that it is for one row and it fits for one row.
And our data is correct.
Let me show you how we do this in practice now.
We're going to use the same math function, but instead of result title, we're mapping over.
We're going to map over result info.
So result info instead of result title.
And then let's make the title element here.
So we say const title element.
And then we use the element selector here.
And then we say dot find.
So Dot Find is going to find child elements of an element.
And then we say dot result title here.
So now we have the title element.
And then we can simply use the title element instead.
So now we still have the title and the URL of the job posting.
So using Dot find, we then go to this parent element and then we say inside this result info element.
Find the children with the class result title.
That's going to be this one.
And then we can select the title and URL just like before.
Now we can do the same thing with the time element so we can say const.
Time element.
And then use the same element selector and then say find and then dot result date.
Because result date is the class of this time element we have here.
And then we can make the date that the job was posted.
So date posted equals.
Then we use the time element selector here and say attribute.
And remember we wanted to get the attribute date time.
So date time.
And then also I would like to have it into a JavaScript date object because it is, after all, a date
that we are saving.
The data is a date.
So let's just make it explicit that it is a date we are messing around with here.
So new date and then we pass in the string of date time to create this object.
And then we can simply add the date posted as another property onto our objects we have here.
Now let's try and run it and see how our results array look like.
And now we can see it is printing out a nice little array with different objects that has a title,
a URL and a date.
It was posted.
And we are pretty sure that it is correct data because we are going through each of these rows in the
same loop.
Now, in the next section, I'm going to show you how we can get the neighborhood that the job was posted
in.
So the neighborhood is the one that is in parenthesis sometimes at the job listings out here.
And you can go ahead and try to do it yourself now.
It's sort of the same thing we've been doing so far.
So I recommend as an exercise that you try and do that now.
And in the next section I'm going to show you how I will do it.
So see you in the next section.