WEBVTT

00:00.840 --> 00:10.770
So when I was originally making this project, I just tried to do a simple request instead.

00:10.800 --> 00:17.230
So I went into Nordstrom.com in here where we have the searches.

00:17.250 --> 00:24.810
I went in search for something, search query like red dresses, and then I tried to disable JavaScript

00:24.810 --> 00:28.170
because I want to see can the site run without JavaScript?

00:28.320 --> 00:35.400
If the site can run without JavaScript, it means that we can use request instead, which uses less

00:35.400 --> 00:39.310
resources than puppeteer or selenium and so on.

00:39.330 --> 00:39.930
Does.

00:41.330 --> 00:46.850
So this little plug in here, it's called just something like disable JavaScript.

00:46.880 --> 00:48.140
You can just search for it.

00:48.140 --> 00:49.730
It's a chrome plugin.

00:50.090 --> 00:59.240
So I click that and and I can see that the site is still being rendered, which means that the site

00:59.240 --> 01:01.400
can run without JavaScript.

01:01.640 --> 01:02.750
Cool enough.

01:03.110 --> 01:10.550
So then what I did is I went ahead and tried to use request to download the site.

01:11.270 --> 01:19.340
But I had some issues getting the same result in request as I had inside of the browser.

01:20.410 --> 01:24.040
So I tried to find out what I was doing wrong and so on.

01:24.040 --> 01:35.500
And then suddenly I stumbled upon some API keys here and I love getting API keys because this means

01:35.500 --> 01:40.810
I can use an API instead of having to build a scraper.

01:41.760 --> 01:46.470
Especially if the API says something like query service API key.

01:46.500 --> 01:48.300
Public API key.

01:49.320 --> 01:53.040
And what we're doing actually is doing a query here.

01:53.040 --> 01:59.130
When you're search, you're doing a query and so query service API.

01:59.160 --> 02:01.410
Sounds very promising.

02:02.970 --> 02:10.170
So let's go ahead and enable JavaScript again because we're talking with some APIs.

02:10.170 --> 02:13.050
That means we need to have JavaScript enabled.

02:14.210 --> 02:16.490
Now let's see what happens.

02:16.490 --> 02:21.620
If we clear this one and I make a search for red dresses.

02:30.960 --> 02:36.840
Okay, then I'm going to stop the recording so it stops putting out more results.

02:37.440 --> 02:46.260
And basically, if you want to keep an eye out, if there's any sort of APIs that you can use, take

02:46.260 --> 02:53.310
a look at how the the network request is being made.

02:53.520 --> 03:03.480
Here we have our network request that is only for a a document type, so we can't use that for a API.

03:04.600 --> 03:12.310
What you want to look for is something like a Json response instead.

03:12.310 --> 03:14.290
Or XHR.

03:15.370 --> 03:18.280
What I did is I searched for Quarry instead.

03:19.970 --> 03:29.210
And query service API is what I saw inside of the source here for the site query service API key.

03:30.980 --> 03:35.530
And well, if you look here, there's two requests.

03:35.540 --> 03:43.040
The first one is for a Http options to get options for the request you can make, I guess.

03:43.610 --> 03:46.220
And here's a Http get.

03:47.480 --> 03:52.190
And if I look inside of the response here.

03:53.320 --> 03:58.390
And copy that inside of Visual Studio to see how it looks like.

04:00.190 --> 04:02.380
And it's going to look like this.

04:03.100 --> 04:09.160
So here we have a Jason with a products array.

04:09.700 --> 04:12.520
And here's a name, the population.

04:12.520 --> 04:15.160
So sequin minidress.

04:15.640 --> 04:20.050
And funny enough, that's the same result we have over here.

04:21.100 --> 04:28.980
And I'm just going to put visual code next to Google Chrome so you can see both.

04:32.700 --> 04:37.320
And that's going to match up with what we have for the first result here.

04:37.350 --> 04:47.100
If you see that a the population so green average rating 4.1 number of reviews.

04:47.100 --> 04:48.480
158.

04:49.680 --> 04:51.480
Uh, lots of info.

04:52.050 --> 04:54.600
Um, an image as well.

04:56.160 --> 04:57.330
Then.

04:57.330 --> 05:00.180
Yeah, lots of images.

05:01.200 --> 05:02.920
We also have a price here.

05:02.940 --> 05:04.230
Original Min Price.

05:04.230 --> 05:05.990
Original Max Price.

05:06.000 --> 05:08.220
Same as we see in here.

05:09.150 --> 05:16.860
And yeah, so here we have a Murray Scoop Actress It's this one.

05:17.340 --> 05:18.420
And.

05:20.250 --> 05:26.910
So that's basically the same information that we see on the page, except for this time it's inside

05:26.910 --> 05:35.820
of an API and it's very nicely formatted, this data inside of the Json compared to having to parse

05:35.820 --> 05:45.450
the HTML, find out which HTML element you need to select to get this data or the images and so on.

05:47.370 --> 05:56.220
So basically, if you want to try and find an API first, look in the network tab at the request, see

05:56.220 --> 05:59.790
if you can find something that looks like an API is being called.

06:00.000 --> 06:03.570
It can be difficult if it's a large site like this one.

06:04.770 --> 06:09.420
Uh, the second option is to look inside of the source of the site.

06:09.450 --> 06:10.570
Try to search.

06:10.590 --> 06:12.570
Just search for API.

06:12.780 --> 06:18.240
See if you can find any strings that look like a API is being called.

06:19.080 --> 06:26.820
And just you can also look in sources sometimes of the page and try and look inside of the the page

06:26.820 --> 06:27.480
source.

06:29.320 --> 06:33.220
Basically snoop around a little bit in the source network tabs.

06:33.250 --> 06:35.410
Try and look for an API you can use.

06:35.410 --> 06:37.030
Sometimes you're lucky.

06:37.060 --> 06:39.040
It's going to save you a lot of work.

06:39.070 --> 06:41.800
It is worth looking for an API.

06:41.830 --> 06:42.670
Definitely.

06:43.530 --> 06:45.180
Again if you can't do that.

06:45.840 --> 06:52.950
Then try and render the site without JavaScript, like disabling JavaScript with the plugin like I did.

06:53.310 --> 06:57.750
If you can run it without JavaScript, then move on to use request.

06:58.520 --> 07:04.750
And last option if you can't render the site without JavaScript use puppeteer.

07:04.760 --> 07:08.300
So puppeteer is like the last option to use.

07:08.660 --> 07:10.190
Now on to the next section.

07:10.250 --> 07:17.210
We're going to try and run the the API inside of Postman and start building our backend.
