Okay, so now you go.
That's cool, Stefan.
That's cool.
But how do I use this with a web scraper instead of just adding two numbers together?
So let's see how we could do that so we could have we have a parser here that's going to pass our HTML.
And then let's also have a, let's call it a getter dot JS, which is going to get the HTML itself from
the side.
So in here we import request.
From request promise.
And then we have the good old, let's call it get HTML with a URL here.
And in here we get the HTML.
So we say await request.
Get your l and, um.
Okay.
Okay, then let's also have a function here for saving the HTML to a file because we're going to use
that for our test.
So let's say function save HTML to file here we have the HTML in and then we also need to import.
F.
S.
So we can save the HTML to our file.
So let's see here.
So we say F.
S right file sync and let's call it just a test dot HTML and let's pass in the HTML here.
So now we save a HTML or HTML file and we can save that and use it inside of our test for the parser
itself.
And then inside of our main function we can call this getter.
Actually, I can just call the getter inside from the file here.
So let's see, we can say HTML, get HTML.
So now I need to go on to Craigslist.
Let's see, we go to a site that we want to scrape and just get the HTML here so we can go into, let's
see, apartments, housing.
Let's take another kind of site.
We have like a list here, like I have with the software development jobs.
It's going to be the same thing except for we're doing it a test test driven way instead.
So here we go.
And we take this URL here for the section we have.
This is musician musicians in this case.
So we say get HTML paste in the URL here and then let's save the file or save the HTML to our file.
Um, actually, I need to put this inside a async function as well because the get HTML, um, is also
a async function.
So I need to put that inside a another async function.
I'm just going to paste that in here.
And then we can call Maine down here in the ghetto.
JS file.
Now time for the moment of truth, which is to run the getter JS file.
And let's see.
So we have a promise object we get here, which is because I don't have a weight in front of get HTML.
So I run it again and this time I'm getting undefined in the HTML because I forgot to return the HTML
up in the get function up here.
So here we have hopefully the full code.
Now let's try and run it the final time and it should be working now.
So here we have all of the San Francisco Bay Area musicians from Craigslist.
So we have some nice HTML here, which is the same well, which is what request would get.
And now we're going to save it and use it inside of the test and basically make out a web scraper this
way without calling the Craigslist site all of the time.