WEBVTT

00:00.680 --> 00:04.610
That's created inside M-lab will be called listings.

00:05.210 --> 00:09.020
And then we have the schema we also pass in so listing schema.

00:10.240 --> 00:16.150
And then we can simply just export this listing model so that we can create it somewhere else.

00:16.150 --> 00:19.990
So module exports and then listing.

00:21.290 --> 00:26.600
Now I can import this model inside of Index.js.

00:26.630 --> 00:29.420
So let's go ahead and do that.

00:29.970 --> 00:34.590
So const listing require.

00:35.280 --> 00:38.790
And then we go into the model folder and say Listing.

00:40.590 --> 00:50.100
And now in here, we can then save the MongoDB model and watch how it comes up in our database.

00:51.720 --> 00:58.590
So now once we are in the scrape job descriptions method, we basically have gotten all the data that

00:58.590 --> 01:01.080
we need for all of these listings.

01:01.080 --> 01:08.910
So then it would be a nice point in time to save this listing data up in the MongoDB database.

01:09.240 --> 01:16.680
Before we move on to the next listing item, so what we can do now is to say we can do something where

01:16.680 --> 01:21.210
we can say await, where we can say const listing model.

01:21.990 --> 01:27.840
And then we can say new listing and then we can just pass in the object of this listing.

01:27.840 --> 01:37.110
So listings on the I index and then we can say listing model dot save and make sure also to have a wait

01:37.110 --> 01:38.220
in front of that.

01:39.820 --> 01:46.900
So now when we run the scraper through, we should be able to see inside the M-lab database that the

01:46.900 --> 01:49.120
listings are being saved up.

01:50.170 --> 01:52.540
Inside the listings collection.

01:52.870 --> 01:55.270
So now I'm going to go ahead and write.

01:55.300 --> 01:57.040
Node Index.js.

01:57.160 --> 02:01.150
And then let's see if it updates our database.

02:03.940 --> 02:07.570
So now it's going through some job descriptions.

02:07.570 --> 02:15.280
And then if I go into let's try and go into M-lab database and see if it saves our listings.

02:15.670 --> 02:22.060
So I can already see when I go into the database for Craigslist listings that there is a new collection

02:22.060 --> 02:26.350
that has been created which is called listings.

02:27.050 --> 02:29.600
And if I click on the collection in here.

02:31.170 --> 02:36.900
I can see all of this collection of listing objects or listing documents.

02:37.530 --> 02:40.880
And in here you can see all of the data that we are saving.

02:40.890 --> 02:48.330
I can see the title, the URL, the date it was posted, and the job description, as well as the compensation

02:48.360 --> 02:49.320
of the job.

02:49.890 --> 02:57.600
There's also been a unique ID that's been attached to the object or the document, which is a MongoDB

02:57.600 --> 02:58.680
specific thing.

02:58.680 --> 03:05.880
It's just a unique ID or a key to lock up to look up an item in the MongoDB database.

03:07.150 --> 03:08.290
So people.

03:08.290 --> 03:10.990
That is all of it.

03:11.560 --> 03:15.310
And now you've seen how to scrape specific data.

03:15.340 --> 03:23.530
You've seen how to open up puppeteer and navigate around on pages with the puppeteer and scrape the

03:23.530 --> 03:26.530
content from a page with Cheveyo as well.

03:26.920 --> 03:31.540
And you also seen how to save the data up into MongoDB.

03:31.930 --> 03:39.160
And yeah, that's all you need to know for a lot of the tasks you'll be doing in the scraping Adventure.

03:39.160 --> 03:46.390
Now you're free to also see my other sections where we also make a API and use a front end to present

03:46.390 --> 03:49.930
the data we are scraping or a CSV file.

03:49.930 --> 03:53.980
If you want to save the data onto a CSV file instead, you can also do that.

03:54.400 --> 04:00.670
I would recommend that you save it onto a database first of all, because then you always have your

04:00.670 --> 04:08.380
data at one place and it's easy to take it from there and manipulate it however you want to use it.

04:10.710 --> 04:12.690
So that's all for now, folks.

04:12.690 --> 04:19.200
If you have any requests or questions, then please let me know and I'll try to get back to you as soon

04:19.200 --> 04:20.070
as possible.
