Skip to content

Commit eb05470

Browse files
committed
fix: update locating to be about JS
1 parent 71fdfa2 commit eb05470

File tree

3 files changed

+171
-163
lines changed

3 files changed

+171
-163
lines changed

sources/academy/webscraping/scraping_basics_javascript2/05_parsing_html.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ LoadedCheerio {
9191
}
9292
```
9393

94-
Our code prints a Cheerio object. It's something like an array of all `h1` elements Cheerio can find in the HTML we gave it. It's the case that there's just one, so we can see only a single item in the container.
94+
Our code prints a Cheerio object. It's something like an array of all `h1` elements Cheerio can find in the HTML we gave it. It's the case that there's just one, so we can see only a single item in the selection.
9595

9696
The item has many properties, such as references to its parent or sibling elements, but most importantly, its name is `h1` and in the `children` property, it contains a single text element. Now let's print just the text. Let's change our program to the following:
9797

@@ -111,7 +111,7 @@ if (response.ok) {
111111
}
112112
```
113113

114-
Thanks to the nature of the Cheerio object we don't have to explicitly find the first element. If we call `.text()`, it automatically assumes we want to work with the first element in the collection. Thus, if we run our scraper again, it prints the text of the first `h1` element:
114+
Thanks to the nature of the Cheerio object we don't have to explicitly find the first element. Calling `.text()` combines texts of all elements in the selection. If we run our scraper again, it prints the text of the `h1` element:
115115

116116
```text
117117
$ node index.js
@@ -146,7 +146,7 @@ if (response.ok) {
146146
}
147147
```
148148

149-
In CSS, `.product-item` selects all elements whose `class` attribute contains value `product-item`. We call `$()` with the selector and get back a container of matching elements. Cheerio handles all the complexity of understanding the HTML markup for us. Then we use `.length` to count how many items there is in the container.
149+
In CSS, `.product-item` selects all elements whose `class` attribute contains value `product-item`. We call `$()` with the selector and get back matching elements. Cheerio handles all the complexity of understanding the HTML markup for us. Then we use `.length` to count how many items there is in the selection.
150150

151151
```text
152152
$ node index.js

0 commit comments

Comments
 (0)