Skip to content

This package get, fetch, crawl, sitemap pages recursively and fetch all links in between <loc> tag.

Notifications You must be signed in to change notification settings

sromexs/get-sitemap-links

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Get Sitemap Links

get sitemap links

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);
})();

About

This package get, fetch, crawl, sitemap pages recursively and fetch all links in between <loc> tag.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published