WEBVTT

00:02.220 --> 00:05.010
Okay, so let's get started writing some code.

00:05.040 --> 00:10.380
First, let's create our index.js file where we'll be having all our code inside.

00:10.740 --> 00:15.300
And then let's start actually importing the cheerio in an access library.

00:15.300 --> 00:22.980
So let's say const Axios require Axios to import the Axios library and cheerio.

00:24.230 --> 00:25.280
In here.

00:26.280 --> 00:29.100
Then let's create a main function.

00:29.100 --> 00:34.470
Let's call it a async function, because we might do a little async calls in here.

00:34.920 --> 00:36.090
Let's say main.

00:36.180 --> 00:38.760
Let's just have this empty function in here.

00:40.050 --> 00:45.780
And let's make sure to call it outside of the function scope down here below.

00:46.590 --> 00:48.420
Then let's call.

00:48.420 --> 00:53.310
Let's call the site I have and let's see if we get some HTML.

00:53.310 --> 01:00.600
So let's call it job index page and we can say await Axios dot get.

01:01.320 --> 01:06.240
And then we want to put in the URL we want to fetch in this case.

01:07.510 --> 01:18.340
We have the URL here from Craigslist, which is Praxis dot vercel dot app slash jobs slash one.

01:18.340 --> 01:19.720
So that's just the page.

01:19.720 --> 01:21.340
One of the jobs.

01:21.340 --> 01:24.820
We're going to make this more dynamic so we can get all the pages.

01:24.820 --> 01:29.230
But for now let's just see if we can get this HTML from the first page.

01:30.660 --> 01:36.840
And then let's try and do a console log of the job index page dot data.

01:36.840 --> 01:43.020
When you use excuse, the dot data is the actual data from the request and everything else.

01:43.020 --> 01:47.340
When you just have the object itself, you get all this metadata about the response.

01:47.850 --> 01:55.560
So now with that written, let's try and see what happens if we type in node index.js and run the code.

01:56.980 --> 02:03.070
So if you run node index.js, you should be getting some output in the console.

02:03.070 --> 02:05.410
Very similar to this code we have here.

02:05.410 --> 02:11.440
So this is just the pure HTML we have from the side that Axios has fetched for us.

02:11.620 --> 02:18.490
And don't worry if it looks like a mess, because in the next section we are going to be using cheerio

02:18.490 --> 02:23.440
to actually extract these job titles from the page.

02:23.950 --> 02:28.420
So I'll see you in the next section where we get the job titles from this side.
