Global

Methods

for_each_page_in_list(type, titleopt, for_each_page, optionsopt) → {Promise}

Source:
Deprecated:
Syntactic sugar for several kinds of lists.
Example

List all redirected categories

// <code>
await wiki.for_each_page_in_list('allredirects', page_data => console.log('page_data: ', page_data), { namespace: 'Category' });
// </code>
Parameters:
Name Type Attributes Description
type String list type
title String <optional>
page title if necessary.
for_each_page function Executing for each page.
options Object <optional>
options to run this function.
Returns:
Type
Promise

Wikiapi_list()

Source:
Tool function to access page list.
Please refer to all supported types (search "get_list.type =").
Examples

get list of [[w:en:Category:Chemical_elements]]

// <code>
const wiki = new Wikiapi;
let page_list = await wiki.categorymembers('Chemical elements');
console.log(page_list);
// Working on multiple pages
await wiki.for_each_page(
	// {Array} title liat / page data list
	page_list,
	page_data => {
		// ...
	});
// </code>

get pages transcluding {{w:en:Periodic table}}

// <code>
const wiki = new Wikiapi;
let page_list = await wiki.embeddedin('Template:Periodic table');
console.log(page_list);
// </code>

Process each page of the category.

// <code>
// Get the list of all pages at once first.
const page_list = await wiki.categorymembers('Category:Articles not listed in the vital article list');
await page_list.each((page_data) => { }, options);

// Imperative code, for huge pages. 用於巨量的頁面。
for await (const page_data of wiki.categorymembers('Category:Articles not listed in the vital article list')) {
	console.trace(`page_data #${count}:`, page_data);
}

// Declarative code(?), for huge pages.
await wiki.categorymembers('Category:Articles not listed in the vital article list', {
	for_each_page(page_data) {
		console.log('page_data:', page_data);
	}
});

await wiki.allpages({
	async for_each_slice(page_list) {
	}
});

// </code>

Process all pages.

// <code>
let count = 0;
for await (const page_data of wiki.allpages({ namespace: 'Talk', apfrom: wiki.remove_namespace('ABC') })) {
	console.trace(`page_data #${count}:`, page_data);
	if (++count > 5) break;
}
console.log('Done.');
// </code>

Process all pages with batch_size.

// <code>
let count = 0;
for await (const page_list of wiki.allpages({ namespace: 'Talk', apfrom: wiki.remove_namespace('ABC'), batch_size: 5 })) {
	console.trace('page_list:', page_list);
	if (++count > 2) break;
}
console.log('Done.');
// </code>