Before we move on to the job description, let's copy paste the code or the selector we have inside
of console for our neighborhood and make a variable.
Call it hood.
Paste the selector inside here and then add it to our result object.
Now the next thing we need to do is we need to go through each of these jobs URL and get their job description.
You can also get their address inside of that page and maybe their compensation.
So first, let's just rename our main function from scrape Craigslist to scrape job header.
Like so.
And then let's make another main function, which we will call scrape Craigslist.
And in here we will make a call for the scrape job header instead and we get the array back from it.
The job array with the headers, with the title and links and so on.
We'll say await and then want to return the scrape results array from here, which contains the title
date.
It was posted and so on.
And then let's make a new function in here, which we call scrape description, where we will be going
through each of the jobs inside of this scrape results array and get the description for the jobs.
So we pass in the array jobs with headers.
And then inside here, we need to do a little magic using Promise.all to iterate through each of these
jobs and make a request.
Let me just show you what we will get from this function.
We will get the jobs with the full data and we pass in the jobs with headers.
Now we say await first and then promise dot all.
So this takes in an array of promises and it's only going to resolve once all of the promises have resolved.
And we use this JavaScript headers dot map to iterate over the array of jobs with headers.
This is basically JavaScript ES6 that I'm showing you here, or Es7.
We iterate over the chops with headers array using map, and then we can go through each chop and make
a request to the chops URL that we got earlier from the main page.
And I'm also throwing in async here as well.
So we can use the await keyword inside of the map function.
So all of this can seem confusing if you don't know ES6 or seven first, but.
If you don't know exactly what I'm doing here, maybe brush up a bit on Es7 or ES6, but hopefully you
will get the gist of how this works.
If you don't know Es7 already.
Then let's make the chario variable just like we did before.
In the job titles.
Now we're just doing it for every job instead.
And then let's get the posting body ID, which contains all of the, um, the job description.
And now let's see how posting body text looks like.
We can see we get all of the job description here, but I don't like the QR code link to this post so
much in the top, so let's try and get rid of that.
Now since the QR code thing is inside of posting body, I think I want to remove this element first
and then we can do the dot text on posting body to get the job description.
Let me show you how that works.
So we can use the print QR code container class to select it.
And then we'll just simply remove it using jQuery.
And now the element has been removed.
And when I use text on posting body again, I can see that there's no longer the QR code link text up
on the top and now we can simply do the exact same thing inside of the NodeJS project.
We will remove the element first to not have the QR code link text in the job description and then use
the text to create our own description variable.
Like so.
And now just let me make a property on the job object.
And we have the job description, basically the job object.
And let's also take the address while we're at it.
Find out where the address is.
So select the element and select the address.
And we can see there's a div with a class map address, so why not try and select this?
You can also use right click copy selector inside of Chrome tools.
But I don't think the selector is always so short or efficient as when you're just making it up yourself.
Let's try and see how this selector looks like.
You can see it's very long because it wants to make sure that we're selecting the exact element.
But in this case, I think we can just use the div and the map address class.
And let's try and look how the text looks for that.
And that's perfect.
We get the address of the job, so let's just copy that and make that as our job dot address.