-
[Sitemapper][2]
- [fetch][3]
- [Parameters][4]
- [Examples][5]
- [getSites][6]
- [Parameters][7]
- [decompressResponseBody][8]
- [Parameters][9]
- [timeout][10]
- [Examples][11]
- [timeout][12]
- [Parameters][13]
- [Examples][14]
- [lastmod][15]
- [Examples][16]
- [lastmod][17]
- [Parameters][18]
- [Examples][19]
- [url][20]
- [Parameters][21]
- [Examples][22]
- [url][23]
- [Examples][24]
- [debug][25]
- [Parameters][26]
- [Examples][27]
- [debug][28]
- [Examples][29]
- [fetch][3]
-
[getSitesCallback][30]
- [Parameters][31]
-
[Timeout][32]
-
[ParseData][33]
- [Properties][34]
- [Examples][35]
-
[SitesData][36]
- [Properties][37]
- [Examples][38]
-
[SitesArray][39]
- [Examples][40]
-
[ErrorDataArray][41]
- [Examples][42]
-
[ErrorData][43]
- [Properties][44]
- [Examples][45]## parseStringPromiseSitemap ParserCopyright (c) 2020 Sean Thomas Burke
Licensed under the MIT license.Meta* author: Sean Burke <@seantomburke>## SitemapperType: [Object][46]### fetchGets the sites from a sitemap.xml with a given URL#### Parameters*
url
[string][47]? the Sitemaps url (e.g [https://wp.seantburke.com/sitemap.xml][48]) (optional, defaultthis.url
)#### Examplesjavascript sitemapper.fetch('example.xml') .then((sites) => console.log(sites));
Returns [Promise][49]<[SitesData][36]> ### getSitesGets the sites from a sitemap.xml with a given URLType: [Function][50]#### Parameters*url
[string][47] url to query (optional, defaultthis.url
)
-
callback
[getSitesCallback][30] callback for sites and errorMeta* deprecated: This is deprecated.### decompressResponseBodyDecompress the gzipped response body using zlib.gunzip#### Parameters*body
[Buffer][51] body of the gzipped fileReturns [Boolean][52] ### timeoutGet the timeout#### Examplesjavascript console.log(sitemapper.timeout);
Returns [Timeout][10] ### timeoutSet the timeout#### Parameters*duration
[Timeout][10] #### Examplesjavascript sitemapper.timeout = 15000; // 15 seconds
### lastmodGet the lastmod minimum value#### Examplesjavascript console.log(sitemapper.lastmod);
Returns [Number][53] ### lastmodSet the lastmod minimum value#### Parameters*timestamp
[Number][53] #### Examplesjavascript sitemapper.lastmod = 1630694181; // Unix timestamp
### url#### Parameters*url
[string][47] url for making requests. Should be a link to a sitemaps.xml#### Examplesjavascript sitemapper.url = 'https://wp.seantburke.com/sitemap.xml'
### urlGet the url to parse#### Examplesjavascript console.log(sitemapper.url)
Returns [string][47] ### debugSetter for the debug state#### Parameters*option
[Boolean][52] set whether to show debug logs in output.#### Examplesjavascript sitemapper.debug = true;
### debugGetter for the debug state#### Examplesjavascript console.log(sitemapper.debug)
Returns [Boolean][52] ## getSitesCallbackCallback for the getSites methodType: [Function][50]### Parameters*error
[Object][46] error from callback -
sites
[Array][54] an Array of sitemaps## TimeoutTimeout in millisecondsType: [Number][53]## ParseDataResolve handler type for the promise in this.parse()Type: [Object][46]### Properties*error
[Error][55] that either comes fromparseStringPromise
orgot
or custom error -
data
[Object][46]-
data.url
[string][47] URL of sitemap -
data.urlset
[Array][54] Array of returned URLsdata.urlset.url
[string][47] single Url
-
data.sitemapindex
[Object][46] index of sitemapdata.sitemapindex.sitemap
[string][47] Sitemap### Examplesjavascript { error: 'There was an error!' data: { url: 'https://linkedin.com', urlset: [{ url: 'https://www.linkedin.com/project1' },[{ url: 'https://www.linkedin.com/project2' }] } }
## SitesDataResolve handler type for the promise in this.parse()Type: [Object][46]### Properties*url
[string][47] the original url used to query the data
-
-
sites
[SitesArray][39] -
errors
[ErrorDataArray][41] ### Examplesjavascript { url: 'https://linkedin.com/sitemap.xml', sites: [ 'https://linkedin.com/project1', 'https://linkedin.com/project2' ], errors: [ { type: 'CancelError', url: 'https://www.walmart.com/sitemap_tp1.xml', retries: 0 }, { type: 'HTTPError', url: 'https://www.walmart.com/sitemap_tp2.xml', retries: 0 }, ] }
## SitesArrayAn array of urlsType: [Array][54]<[String][47]>### Examplesjavascript [ 'https://www.google.com', 'https://www.linkedin.com' ]
## ErrorDataArrayAn array of Error data objectsType: [Array][54]<[ErrorData][43]>### Examplesjavascript [ { type: 'CancelError', url: 'https://www.walmart.com/sitemap_tp1.xml', retries: 0 }, { type: 'HTTPError', url: 'https://www.walmart.com/sitemap_tp2.xml', retries: 0 }, ]
## ErrorDataAn object containing details about the errors which occurred during the crawlType: [Object][46]### Properties*type
[string][47] The error type which was returned -
url
[string][47] The sitemap URL which returned the error -
errors
[Number][53] The total number of retries attempted after receiving the first error### Examples```javascript { type: 'CancelError', url: 'https://www.walmart.com/sitemap_tp1.xml', retries: 0 }