When we click on each shop, we get taken to a shop description page.
Now that we got the title of this shop, we are looking to get each individual URL for these shops.
So as before, we let's right click on the element and select inspect and see how we could approach
this.
We can see here there is an A element which has our date of interest the href attribute.
Now we want to extract only this riff attribute.
But how could we do this?
Well, we first need to be able to select all of these A elements.
We could use a selector to go something like this.
The title plop with a child selector of a.
Another way of doing it.
If you want to be inspired and maybe you're dealing with some very nested HTML, is to use the copy
selector function inside of Chrome.
So you will right click your element of interest, which is in here in the Element Inspector.
And you could select copy and select Copy Selector.
And then try pasting in the selector inside of Google Chrome Console and see how it looks like.
So you can see the one that I copied here is very long compared to the one I just came up with by looking
at the code.
And usually I mean this is only going to select the very first element up here, which is the child
of the first child we are selecting here.
So sometimes when you copy the selectors you're just going to have to take only the the later part,
which is ending up being pretty much the same as the one I came up with.
So let's try and see if our new selector works.
I'm just going to go ahead and use dot title plot instead because it's shorter.
So if that works then I'm going to go with that.
And we use the jQuery selector and we can say dot text, and we can see we get all the titles again.
But what about the links of the A elements?
Well, in order to get that we are going to use the attribute function instead.
And we're going to specify specifically select the href attribute that we want to get.
And as we can see here, we are now getting the link of the first shop title or the first shop in this
page.
But how about all the other jobs?
We're not going to just take our chance with one job here.
We of course want to spam our resume to everyone out there.
So in order to get all the other URLs, we can again use this dot each loop similar to what we did with
the titles.
So we can say dot each and say index element and then use an arrow function.
And we can say console log.
And we have the element again inside the cherry jQuery selector.
And we say dot uh attribute with the href attribute we want to output.
And says, I'm missing a parenthesis.
That happens sometimes with all those parentheses you have to put in.
And there we go.
We can now see we get all of the job URLs.
So in the next section we are going to see how we can optimize our Node.js code a little bit.
And we're also going to output in the job URLs inside of Node.js.
So I'll see you in the next section.