0
Get sitemaps samples out of config
One script reply has been approved by the moderators Verified

Sample list of URLs which were found in your sitemaps but outside of the crawl perimeter defined for the project, for instance domain/subdomain or protocol (HTTP/HTTPS) not allowed in the crawl settings.

Created by hugo697 37 days ago Viewed 3 times
0
Submitted by hugo697 Bun
Verified 37 days ago
1
//native
2
type Botify = {
3
	token: string
4
}
5
/**
6
 * Get sitemaps samples out of config
7
 * Sample list of URLs which were found in your sitemaps but outside of the crawl perimeter defined for the project, for instance domain/subdomain or protocol (HTTP/HTTPS) not allowed in the crawl settings.
8
 */
9
export async function main(
10
	auth: Botify,
11
	username: string,
12
	project_slug: string,
13
	analysis_slug: string,
14
	page: string | undefined,
15
	size: string | undefined
16
) {
17
	const url = new URL(
18
		`https://api.botify.com/analyses/${username}/${project_slug}/${analysis_slug}/features/sitemaps/samples/out_of_config`
19
	)
20
	for (const [k, v] of [
21
		['page', page],
22
		['size', size]
23
	]) {
24
		if (v !== undefined && v !== '' && k !== undefined) {
25
			url.searchParams.append(k, v)
26
		}
27
	}
28
	const response = await fetch(url, {
29
		method: 'GET',
30
		headers: {
31
			Authorization: 'Token ' + auth.token
32
		},
33
		body: undefined
34
	})
35
	if (!response.ok) {
36
		const text = await response.text()
37
		throw new Error(`${response.status} ${text}`)
38
	}
39
	return await response.text()
40
}
41