docs: change html example to use items variable instead of item (#14205)

* change html example to use items variable instead of item

The existing example for HTML retrieval uses 'item' variable on item retrieval, but the final rss output uses the 'items' variable. This results in undefined variable for anyone who directly uses the example code.

* docs: fix cn docs too

---------
This commit is contained in:
Manish Bhattarai 2024-01-07 23:16:11 -05:00 committed by GitHub
parent 86dfd066d4
commit 176341e95b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -320,7 +320,7 @@ Next, we'll use Cheerio selectors to select the relevant HTML elements, parse th
// We use a Cheerio selector to select all 'div' elements with the class name 'js-navigation-container'
// that contain child elements with the class name 'flex-auto'.
// highlight-start
const item = $('div.js-navigation-container .flex-auto')
const items = $('div.js-navigation-container .flex-auto')
// We use the `toArray()` method to retrieve all the DOM elements selected as an array.
.toArray()
// We use the `map()` method to traverse the array and parse the data we need from each element.
@ -366,7 +366,7 @@ module.exports = async (ctx) => {
const { data: response } = await got(`${baseUrl}/${user}/${repo}/issues`);
const $ = cheerio.load(response);
const item = $('div.js-navigation-container .flex-auto')
const items = $('div.js-navigation-container .flex-auto')
.toArray()
.map((item) => {
item = $(item);

View File

@ -317,7 +317,7 @@ module.exports = async (ctx) => {
// 我们使用 Cheerio 选择器选择所有带类名“js-navigation-container”的“div”元素
// 其中包含带类名“flex-auto”的子元素。
// highlight-start
const item = $('div.js-navigation-container .flex-auto')
const items = $('div.js-navigation-container .flex-auto')
// 使用“toArray()”方法将选择的所有 DOM 元素以数组的形式返回。
.toArray()
// 使用“map()”方法遍历数组,并从每个元素中解析需要的数据。
@ -363,7 +363,7 @@ module.exports = async (ctx) => {
const { data: response } = await got(`${baseUrl}/${user}/${repo}/issues`);
const $ = cheerio.load(response);
const item = $('div.js-navigation-container .flex-auto')
const items = $('div.js-navigation-container .flex-auto')
.toArray()
.map((item) => {
item = $(item);