So when I was originally making this project, I just tried to do a simple request instead.
So I went into Nordstrom.com in here where we have the searches.
I went in search for something, search query like red dresses, and then I tried to disable JavaScript
because I want to see can the site run without JavaScript?
If the site can run without JavaScript, it means that we can use request instead, which uses less
resources than puppeteer or selenium and so on.
Does.
So this little plug in here, it's called just something like disable JavaScript.
You can just search for it.
It's a chrome plugin.
So I click that and and I can see that the site is still being rendered, which means that the site
can run without JavaScript.
Cool enough.
So then what I did is I went ahead and tried to use request to download the site.
But I had some issues getting the same result in request as I had inside of the browser.
So I tried to find out what I was doing wrong and so on.
And then suddenly I stumbled upon some API keys here and I love getting API keys because this means
I can use an API instead of having to build a scraper.
Especially if the API says something like query service API key.
Public API key.
And what we're doing actually is doing a query here.
When you're search, you're doing a query and so query service API.
Sounds very promising.
So let's go ahead and enable JavaScript again because we're talking with some APIs.
That means we need to have JavaScript enabled.
Now let's see what happens.
If we clear this one and I make a search for red dresses.
Okay, then I'm going to stop the recording so it stops putting out more results.
And basically, if you want to keep an eye out, if there's any sort of APIs that you can use, take
a look at how the the network request is being made.
Here we have our network request that is only for a a document type, so we can't use that for a API.
What you want to look for is something like a Json response instead.
Or XHR.
What I did is I searched for Quarry instead.
And query service API is what I saw inside of the source here for the site query service API key.
And well, if you look here, there's two requests.
The first one is for a Http options to get options for the request you can make, I guess.
And here's a Http get.
And if I look inside of the response here.
And copy that inside of Visual Studio to see how it looks like.
And it's going to look like this.
So here we have a Jason with a products array.
And here's a name, the population.
So sequin minidress.
And funny enough, that's the same result we have over here.
And I'm just going to put visual code next to Google Chrome so you can see both.
And that's going to match up with what we have for the first result here.
If you see that a the population so green average rating 4.1 number of reviews.
158.
Uh, lots of info.
Um, an image as well.
Then.
Yeah, lots of images.
We also have a price here.
Original Min Price.
Original Max Price.
Same as we see in here.
And yeah, so here we have a Murray Scoop Actress It's this one.
And.
So that's basically the same information that we see on the page, except for this time it's inside
of an API and it's very nicely formatted, this data inside of the Json compared to having to parse
the HTML, find out which HTML element you need to select to get this data or the images and so on.
So basically, if you want to try and find an API first, look in the network tab at the request, see
if you can find something that looks like an API is being called.
It can be difficult if it's a large site like this one.
Uh, the second option is to look inside of the source of the site.
Try to search.
Just search for API.
See if you can find any strings that look like a API is being called.
And just you can also look in sources sometimes of the page and try and look inside of the the page
source.
Basically snoop around a little bit in the source network tabs.
Try and look for an API you can use.
Sometimes you're lucky.
It's going to save you a lot of work.
It is worth looking for an API.
Definitely.
Again if you can't do that.
Then try and render the site without JavaScript, like disabling JavaScript with the plugin like I did.
If you can run it without JavaScript, then move on to use request.
And last option if you can't render the site without JavaScript use puppeteer.
So puppeteer is like the last option to use.
Now on to the next section.
We're going to try and run the the API inside of Postman and start building our backend.