WEBVTT

00:02.220 --> 00:03.120
Okay, everyone.

00:03.120 --> 00:10.050
Now let's extend our script so that we can start scraping the description pages of all the homes we

00:10.050 --> 00:12.270
get inside of this function.

00:13.440 --> 00:18.000
So to do that, let's go ahead and make a new function.

00:18.390 --> 00:19.920
Let's call it main.

00:21.240 --> 00:33.840
And inside Main, we cut this function, call in here and we say we want to return a homes array from

00:33.840 --> 00:34.650
this one.

00:35.100 --> 00:40.440
So const homes await and then we want to change this one.

00:40.710 --> 00:49.290
The function down here to say return homes instead and then I'm going to remove the console log.

00:50.370 --> 00:57.570
And now let's put the console log down here instead to see if we get the array that we want.

00:57.990 --> 01:01.930
And then we are going to call Main in the script instead.

01:02.710 --> 01:09.790
So what we are doing here is we're trying to return an array here and then we can make a new call to

01:09.790 --> 01:17.170
another function pass in the array so we can go through each of the homes URLs.

01:17.350 --> 01:24.580
And the reason I'm making a function is because we need to use I want to use the await keyword and we

01:24.580 --> 01:28.990
can't use the await keyword outside in the global scope.

01:30.010 --> 01:34.180
So let's try and run it and see if it's still working.

01:40.630 --> 01:47.770
And we seem to be getting a nice list of URLs for the different rooms in the Airbnb site.

01:48.820 --> 01:59.440
One thing to notice is that we need to have a Https in front of the links so or else the puppeteer browser

01:59.440 --> 02:04.990
is not going to accept the URLs if you pass them in.

02:05.500 --> 02:11.620
So we need to change this one up here where it returns the element of your URLs.

02:11.770 --> 02:19.570
We need to change that and put in Https in front like this and we should be good to go.

02:19.570 --> 02:26.890
So I'm just going to run it once more and we should see https in front of the URLs.

02:33.620 --> 02:34.780
And there we go.

02:34.790 --> 02:41.180
So now we're getting all the URLs and it's ready to be passed into our next function where we're going

02:41.180 --> 02:45.200
to go into the description pages, all of these different pages.
