npm

Don't miss out on this year's npm Pride t-shirt designs!Order your favorites here »

@cabbiepete/sitemapper

3.0.2 • Public • Published

Sitemap-parser

Insipired by https://github.com/hawaiianchimp/sitemapper

Allows loading of sitemap.xml.gz files.

// TODO badges Build Status Monthly Downloads npm version dependencies Status Inline docs

Parse through a sitemaps xml to get all the urls for your crawler.

Version 3

Installation

npm install @cabbiepete/sitemapper

Simple Example

const Sitemapper = require('sitemapper');
 
const sitemap = new Sitemapper();
 
sitemap.fetch('http://wp.seantburke.com/sitemap.xml').then(function(sites) {
  console.log(sites);
});
 

Examples in ES5

const Sitemapper = require('sitemapper');
 
const Google = new Sitemapper({
  url: 'https://www.google.com/work/sitemap.xml',
  timeout: 15000 //15 seconds
});
 
Google.fetch()
  .then(function (data) {
    console.log(data);
  })
  .catch(function (error) {
    console.log(error);
  });
 
 
// or
 
 
const sitemap = new Sitemapper();
 
sitemapper.timeout = 5000;
sitemapper.fetch('http://wp.seantburke.com/sitemap.xml')
  .then(function (data) {
    console.log(data);
  })
  .catch(function (error) {
    console.log(error);
  });
 

Examples in ES6

import Sitemapper from 'sitemapper';
 
const Google = new Sitemapper({
  url: 'https://www.google.com/work/sitemap.xml',
  timeout: 15000, // 15 seconds
});
 
Google.fetch()
  .then(data => console.log(data.sites))
  .catch(error => console.log(error));
 
 
// or
 
 
const sitemapper = new Sitemapper();
sitemapper.timeout = 5000;
 
sitemapper.fetch('http://wp.seantburke.com/sitemap.xml')
  .then(({ url, sites }) => console.log(`url:${url}`, 'sites:', sites))
  .catch(error => console.log(error));

install

npm i @cabbiepete/sitemapper

Downloadsweekly downloads

3

version

3.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability