Yaoi-Spinner/scraper.js
2024-12-19 02:13:15 -06:00

29 lines
No EOL
748 B
JavaScript

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
}