get-sitemap-links
v1.1.0
Published
get fetch parse crawl sitemap links recursively.
Downloads
2,549
Maintainers
Readme
Get Sitemap Links
is a TypeScript library that fetches all links recursively from a sitemap page. It can be used in both Node.js and TypeScript applications.
Installation
You can install the package using npm:
npm i get-sitemap-links
Example
This is simple usage of the this tool we can get all links of the sitemap url :
const array = await GetSitemapLinks(
"https://example.com/sitemap.xml"
);
// Output :
// array = [
// "https://example.ir/post/1",
// "https://example.ir/post/2",
// "https://example.ir/post/3",
// "https://example.ir/post/4",
// ...
// ]
With Node.js:
const GetSitemapLinks = require("get-sitemap-links").default;
(async () => {
const array = await GetSitemapLinks(
"https://nexload.ir/wp-sitemap-posts-post-1.xml"
);
console.log(array.length);
})();
With Typescript:
import GetSitemapLinks from "get-sitemap-links";
(async () => {
const array = await GetSitemapLinks(
"https://nexload.ir/wp-sitemap-posts-post-1.xml"
);
console.log(array.length);
})();
Options
(async () => {
const array = await GetSitemapLinks("https://nexload.ir/wp-sitemap.xml", {
filterIndexes: "posts",
// Here we say we just want indexes that includes "posts" string
// This option only works when givin sitemap link is IndexPage like example.com/sitemap.xml
});
console.log(array.length);
})();