Yaoi-Spinner/scraper.js

29 lines
748 B
JavaScript
Raw Permalink Normal View History

2024-12-19 02:13:15 -06:00
import { Scraper } from "@the-convocation/twitter-scraper"
import { flavors, variety } from "./constants.js"
const scraper = new Scraper({
})
await scraper.login(process.env.USERNAME, process.env.PASSWORD)
export async function scrapeYaoi() {
var finalArray = []
for (let flavor of flavors) {
console.log(flavor)
var search = scraper.searchTweets(flavor, variety, "media")
for await (var value of search) {
if (value.html.includes("img")) {
finalArray.push(value)
}
}
}
return finalArray
}
export var yaoiList = await scrapeYaoi()
export function getYaoi() {
var yaoi = yaoiList[Math.floor(Math.random() * yaoiList.length)]
return yaoi
}