WEBVTT

00:00.930 --> 00:06.210
When we click on each shop, we get taken to a shop description page.

00:06.390 --> 00:13.380
Now that we got the title of this shop, we are looking to get each individual URL for these shops.

00:15.290 --> 00:22.100
So as before, we let's right click on the element and select inspect and see how we could approach

00:22.100 --> 00:22.700
this.

00:23.330 --> 00:30.020
We can see here there is an A element which has our date of interest the href attribute.

00:31.560 --> 00:35.400
Now we want to extract only this riff attribute.

00:35.400 --> 00:37.080
But how could we do this?

00:37.110 --> 00:41.550
Well, we first need to be able to select all of these A elements.

00:42.030 --> 00:45.810
We could use a selector to go something like this.

00:47.370 --> 00:51.720
The title plop with a child selector of a.

00:52.990 --> 00:54.640
Another way of doing it.

00:54.640 --> 01:03.760
If you want to be inspired and maybe you're dealing with some very nested HTML, is to use the copy

01:03.760 --> 01:05.950
selector function inside of Chrome.

01:06.700 --> 01:12.910
So you will right click your element of interest, which is in here in the Element Inspector.

01:13.000 --> 01:17.530
And you could select copy and select Copy Selector.

01:18.130 --> 01:24.340
And then try pasting in the selector inside of Google Chrome Console and see how it looks like.

01:24.490 --> 01:30.520
So you can see the one that I copied here is very long compared to the one I just came up with by looking

01:30.520 --> 01:31.540
at the code.

01:31.720 --> 01:38.260
And usually I mean this is only going to select the very first element up here, which is the child

01:38.260 --> 01:41.260
of the first child we are selecting here.

01:41.470 --> 01:48.220
So sometimes when you copy the selectors you're just going to have to take only the the later part,

01:48.220 --> 01:52.210
which is ending up being pretty much the same as the one I came up with.

01:52.240 --> 01:56.290
So let's try and see if our new selector works.

01:56.290 --> 02:01.420
I'm just going to go ahead and use dot title plot instead because it's shorter.

02:01.420 --> 02:04.240
So if that works then I'm going to go with that.

02:04.990 --> 02:12.850
And we use the jQuery selector and we can say dot text, and we can see we get all the titles again.

02:13.240 --> 02:17.530
But what about the links of the A elements?

02:17.560 --> 02:22.180
Well, in order to get that we are going to use the attribute function instead.

02:22.180 --> 02:28.060
And we're going to specify specifically select the href attribute that we want to get.

02:28.750 --> 02:35.740
And as we can see here, we are now getting the link of the first shop title or the first shop in this

02:35.740 --> 02:36.430
page.

02:39.160 --> 02:41.260
But how about all the other jobs?

02:41.260 --> 02:43.840
We're not going to just take our chance with one job here.

02:43.840 --> 02:48.400
We of course want to spam our resume to everyone out there.

02:48.400 --> 02:55.390
So in order to get all the other URLs, we can again use this dot each loop similar to what we did with

02:55.390 --> 02:56.410
the titles.

02:56.710 --> 03:05.620
So we can say dot each and say index element and then use an arrow function.

03:05.620 --> 03:08.830
And we can say console log.

03:09.070 --> 03:14.800
And we have the element again inside the cherry jQuery selector.

03:14.830 --> 03:21.310
And we say dot uh attribute with the href attribute we want to output.

03:23.240 --> 03:26.690
And says, I'm missing a parenthesis.

03:26.690 --> 03:30.320
That happens sometimes with all those parentheses you have to put in.

03:30.320 --> 03:31.250
And there we go.

03:31.250 --> 03:34.730
We can now see we get all of the job URLs.

03:34.730 --> 03:41.210
So in the next section we are going to see how we can optimize our Node.js code a little bit.

03:41.210 --> 03:45.740
And we're also going to output in the job URLs inside of Node.js.

03:45.740 --> 03:48.530
So I'll see you in the next section.
