WEBVTT

00:00.540 --> 00:01.050
Okay.

00:01.050 --> 00:02.640
So far, so good.

00:02.640 --> 00:09.120
We got the first data cell inside of the table now, but now we need to get all of the data inside of

00:09.120 --> 00:09.720
the table.

00:09.720 --> 00:10.770
So how can we do that?

00:10.770 --> 00:17.220
Well, we simply need to remove these nth child selectors we have up in our selector.

00:17.220 --> 00:25.260
So if we take the same selector we had before and now we can remove the nth child up until the column

00:25.260 --> 00:26.000
we have.

00:26.010 --> 00:28.290
So up until here and here.

00:28.290 --> 00:34.500
So we are sitting with this kind of selector, which is then going to select all of the table rows and

00:34.500 --> 00:37.470
all of the table data cells.

00:37.470 --> 00:47.010
So now if we try and say Enter here, we can see all of the names inside of the table all the way from

00:47.010 --> 00:53.640
the first table row, because the first table, I mean from the second table row because the first table

00:53.640 --> 00:57.720
row is elements, the table headers.

00:57.720 --> 01:00.000
So it's not a TD element.

01:00.750 --> 01:07.320
So basically it gets all of the elements, which is all of this, which is all the data from the table

01:07.320 --> 01:09.000
anyway that we want to get.

01:09.150 --> 01:11.790
And we simply print out all of the names.

01:12.030 --> 01:18.930
But as you can notice here, we don't have any spaces besides the spaces we have between the names.

01:18.960 --> 01:21.810
It just moves on to the next table cell.

01:21.810 --> 01:28.500
And when you're dealing with this data inside of JavaScript and can be hard, it can be quite hard to

01:29.070 --> 01:32.070
distinguish which one is which.

01:32.070 --> 01:35.070
So you don't know which name belongs to which column.

01:36.120 --> 01:40.380
You don't know if it's Alfred Fowler kissed Maria or it's.

01:40.380 --> 01:42.330
If it's Alfred Fowler kissed.

01:42.360 --> 01:43.230
You don't know.

01:43.260 --> 01:49.050
You can't see that when the computer just has this long string with no spaces or anything between the

01:49.050 --> 01:49.740
names.

01:49.890 --> 01:51.720
But we can do something.

01:51.720 --> 01:56.580
We can do a dot each loop for each of the elements that we get.

01:56.880 --> 02:03.040
Now, the text like this just takes all of the elements text and just make one long string.

02:03.060 --> 02:10.770
But if we want the cells to be from each line, then we have to make a loop instead for each of the

02:10.770 --> 02:11.580
elements.

02:12.010 --> 02:17.850
Anyway, it's probably going to make more sense when I write out the code here, so let's write it out.

02:19.040 --> 02:25.250
So we have instead of the text, we have a dot each loop instead.

02:25.250 --> 02:30.200
And this dot each loop have an index and an element inside.

02:30.290 --> 02:36.260
So the index is just the index of this array of elements we have.

02:36.260 --> 02:38.720
So index zero is the first element.

02:38.720 --> 02:44.090
Index one is the next one and so on, and the element is the object itself.

02:44.670 --> 02:46.800
Then we have this arrow function.

02:46.800 --> 02:49.410
So this is just a function inside the loop.

02:50.110 --> 02:55.840
And then we have a curly brace where we have the code we can write inside the loop.

02:56.140 --> 03:03.430
And I made a enter here inside Chrome tools with shift insert to make a line break so that we don't

03:03.430 --> 03:08.080
have this long, long one long line of code instead.

03:08.080 --> 03:12.130
So it's a little easier for us to read it anyway.

03:12.130 --> 03:16.960
Then we use the no, actually we do a console log.

03:18.100 --> 03:20.140
And I will use the jQuery library.

03:20.170 --> 03:21.640
Again, the dollar sign.

03:21.640 --> 03:29.890
And we select this element that we have inside the loop and we get the text content from this element.

03:30.880 --> 03:35.260
In this case, it's the first data cell and the second one and so on.

03:35.770 --> 03:42.430
And then we close the function here inside the loop with the curly brace and then a parenthesis at the

03:42.430 --> 03:46.760
end to close the each parenthesis we have up here.

03:46.780 --> 03:47.620
And that's it.

03:47.650 --> 03:50.920
Now let's try and press enter and see what the loop does.

03:50.950 --> 03:58.030
You can see now all of the names inside of the table is printed out from the start to the last one at

03:58.030 --> 03:59.500
the end, the UK.

04:00.160 --> 04:01.060
So there we go.

04:01.060 --> 04:04.930
So now we get all of the names and data inside of the table.

04:04.960 --> 04:11.140
Now let's try and see the next section how we can do this inside of Node JS So we don't have to have

04:11.140 --> 04:14.320
our browser open to scrape websites.
