Edits history of script submission #9438 for ' Get crawl statistics urls (botify)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Botify = {
    	token: string
    }
    /**
     * Get crawl statistics urls
     * Return a list of 1000 latest URLs crawled (all crawled URLs or only URLS with HTTP errors)
     */
    export async function main(
    	auth: Botify,
    	username: string,
    	project_slug: string,
    	analysis_slug: string,
    	list_type: string
    ) {
    	const url = new URL(
    		`https://api.botify.com/analyses/${username}/${project_slug}/${analysis_slug}/crawl_statistics/urls/${list_type}`
    	)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Token ' + auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 566 days ago