WEBVTT

00:00.200 --> 00:07.610
So now it's time for us to actually start out writing the parser so we can get our test passing and.

00:08.640 --> 00:15.000
Remember from the first original Craigslist tutorial that we found out all of the info that we wanted

00:15.030 --> 00:18.150
is inside this result info element.

00:19.740 --> 00:21.780
So we have the result info.

00:21.780 --> 00:28.860
And in here there's the date and the title and the URL and also the neighborhood.

00:29.400 --> 00:37.290
So if we go and select the result info class here, we should be able to get some info for all these

00:37.290 --> 00:38.220
listings.

00:38.490 --> 00:45.600
First, let's write out the listings function here where we take in the HTML.

00:47.060 --> 00:55.580
And then we define this dollar sign or jQuery variable using Cheerio load HTML so we can select all

00:55.580 --> 00:56.660
of the elements.

00:57.140 --> 01:02.300
So then we can say dollar sign and pass in this result info.

01:02.570 --> 01:11.360
And now since the result info is a CSS class, we need to put a dot in front of it to select it in jQuery.

01:12.110 --> 01:19.250
And then we can say dot map where we have a index and then the element.

01:20.310 --> 01:25.890
So that's going to map over each of these elements we have on this page.

01:27.760 --> 01:34.090
And well, also, let's define a variable here, which is called listings.

01:34.980 --> 01:38.100
Actually we can just say return here.

01:38.100 --> 01:48.390
And then also remember to have Dot get at the end of this map of this map call and dot get simply means

01:48.390 --> 01:53.640
that we need to get this array of elements that we have been mapping over through.

01:54.420 --> 01:58.200
Now back to getting the title.

01:59.050 --> 02:00.840
So result info.

02:00.850 --> 02:02.230
That's the elements we're getting.

02:02.230 --> 02:08.680
And then we need to find this child element, which is called result title and header link.

02:09.470 --> 02:18.050
So the the CSS class which resolved title and header link, we need to extract that from this result

02:18.050 --> 02:18.830
info.

02:19.790 --> 02:28.820
So the way to do that is we can say const title equals then the dollar sign and then we pass in this

02:28.820 --> 02:37.100
element we currently have and we find the element or the child element that has the class of this one.

02:38.900 --> 02:43.880
And remember, since it's CSS classes, we need to have dots in front of them.

02:45.260 --> 02:46.460
Just like that.

02:47.210 --> 02:56.240
And then we can simply say dot text because it's just the text contents of this, this element that

02:56.240 --> 02:57.260
is the title.

02:59.410 --> 03:03.610
And then we have the title and then we can say return.

03:04.550 --> 03:05.210
Title.

03:06.320 --> 03:08.060
Now let's see how it looks.

03:08.090 --> 03:17.150
Okay, we already have two test that is passed, and that's probably the the one for the title and the

03:17.150 --> 03:26.660
one for getting the length of the listings because now we already have a 120 elements in this array

03:26.930 --> 03:30.350
and but they don't have all the properties.

03:30.350 --> 03:38.330
But we have 120 elements in the listings array and we also have the titles for the first element.
