javascript
const fs = require('fs')
const path = require('path')
const fetch = require('node-fetch')
const getUrls = async () => {
const url = `https://www.freecrosswordsolver.com/sitemap-answers.xml`
const response = await fetch(url)
if (!response) {
return []
}
const text = await response.text()
return text.match(/https:\/\/www\.freecrosswordsolver\.com\/sitemap-answers-\d+\.xml/g)
.map((url) => fetch(url))
}
const getWords = async (urls) => {
const words = []
for await (const response of urls) {
console.time('i')
// const response = await fetch(url)
if (!response) {
continue
}
const text = await response.text()
const match = text.match(/(?<=<loc>https:\/\/www\.freecrosswordsolver\.com\/answer\/)\w+(?=<\/loc>)/g)
if (match) {
words.push(...match)
}
console.timeEnd('i')
}
return words
}
(async () => {
const urls = await getUrls()
console.log(urls.length)
const words = await getWords(urls)
console.log(words.length)
const unique = [...new Set(words)]
.filter(({ length }) => length > 2)
.sort((a, b) => a.length - b.length || a.localeCompare(b))
console.log(unique.length)
fs.writeFileSync(path.resolve('words.txt'), unique.join('\n'))
})()
Syntax Highlight Bot
Vladislav
Lupusregina[beta]
Vyacheslav
Andrejs Sahniks
Denis