Skip to content

Instantly share code, notes, and snippets.

@Saiv46
Last active September 13, 2021 16:37
Show Gist options
  • Save Saiv46/01880638ba3c91cbb4b777d24fc54d15 to your computer and use it in GitHub Desktop.
Save Saiv46/01880638ba3c91cbb4b777d24fc54d15 to your computer and use it in GitHub Desktop.
RU Hentai Search Stat
// https://trends.google.com/trends/explore?date=all&geo=RU&q=hentai
const makeRequest = async (url, params = {}) => {
const res = await fetch(`${url}?${new URLSearchParams(params)}`)
if (!res.ok) {
console.warn(`Got code ${res.status}`, url, params)
await new Promise(res => setTimeout(res, 3000 + Math.random() * 5000 | 0))
console.info(`Retrying...`, url, params)
return makeRequest(url, params)
}
return JSON.parse((await res.text()).substr(5))
}
const fetchStatByTag = async tag => {
const { request, token } = (await makeRequest('https://trends.google.com/trends/api/explore', { hl: 'ru', tz: -480, req: JSON.stringify({comparisonItem: [{keyword: tag, geo: "RU", time: "today 1-m"}],category: 0, property: ''}) })).widgets[1]
const { default: { geoMapData } } = await makeRequest('https://trends.google.com/trends/api/widgetdata/comparedgeo', { hl: 'ru', tz: -480, req: JSON.stringify(request), token })
return Object.fromEntries(
geoMapData
.map(v => [v.geoName, v.value[0]])
)
}
const tags = 'ahegao,anal,apron,beauty mark,big dick,biting,blindfold,blowjob,body swap,book,booty,bukkake,bunny girl,busty,catgirl,cheating,cheerleader,chikan,christmas,chubby,comedy,condom,creampie,crossdressing,crotch tattoo,cunnilingus,dark skin,deepthroat,double penetration,doujin,dubbed,elf,exhibitionism,eyebrows,eyepatch,facesitting,fangs,fantasy,femboy,femdom,filming,footjob,foreigner,freckles,futanari,genderbend,glasses,group,hairy armpit,handjob,harem,headphones,heart pupils,historical,horns,horror,housewife,huge boobs,idol,impregnation,inseki,interview,inverted nipples,isekai,kimono,kogal,lactation,lingerie,love hotel,magical girl,maid,masturbation,miko,monster girl,muscles,music,netorare,netorase,netori,newhalf,ninja,nun,nurse,office lady,ojousama,ongoing,oni,orgasm denial,osananajimi,paizuri,pegging,petite,platformer,ponytail,pregnant,pubic hair,puzzle,qipao,rimjob,schoolgirl outfit,sci-fi,shimapan,slice of life,socks,spats,spread,squirting,stockings,subbed,succubus,swimsuit,swinging,tanlines,teacher,tomboy,toys,trans,tsundere,twintails,ugly bastard,uncensored,unlimited,vanilla,voyeurism,waitress,western,whiteout,x-ray,yandere,yaoi,yuri'.split(',')
const tagsData = await Promise.all(tags.map(v => fetchStatByTag(v).then(r => [v, r])))
const regionData = {}
for (const [ tag, regions ] of tagsData) {
for (const region in regions) {
const value = regions[region]
if (!regionData[region] || value > regionData[region][1]) {
regionData[region] = [ tag, value ]
}
}
}
console.table({ 'Регион': ['Самый популярный тэг', 'Региональная популярность (%)'], ...regionData})
// https://wordstat.yandex.ru/#!/regions?filter=regions&map=ru&words=hentai
const decodeResponse = ({ key, data }) => {
key = navigator.userAgent.substr(0, 25) + ($.cookie("fuid01") || "") + eval(key)
return JSON.parse(decodeURIComponent(Array.from(data, (v, i) => String.fromCharCode(v.charCodeAt(0) ^ key.charCodeAt(i % key.length))).join('')))
}
const fetchStatByTag = async tag => {
const res = await fetch('https://wordstat.yandex.ru/stat/regions', {
method: 'POST',
mode: 'same-origin',
cache: 'no-cache',
credentials: 'include',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: `db=&filter=regions&map=ru&page=1&page_type=regions&period=monthly&regions=&sort=cnt&type=list&words=hentai+${tag}`
})
const data = decodeResponse(await res.json())
return Object.fromEntries(
data.content.js.regions
.filter(v => v.am && v.am.startsWith('RU_'))
.map(v => [v.name, parseInt(v.cnt)])
)
}
const tags = 'ahegao,anal,apron,beauty mark,big dick,biting,blindfold,blowjob,body swap,book,booty,bukkake,bunny girl,busty,catgirl,cheating,cheerleader,chikan,christmas,chubby,comedy,condom,creampie,crossdressing,crotch tattoo,cunnilingus,dark skin,deepthroat,double penetration,doujin,dubbed,elf,exhibitionism,eyebrows,eyepatch,facesitting,fangs,fantasy,femboy,femdom,filming,footjob,foreigner,freckles,futanari,genderbend,glasses,group,hairy armpit,handjob,harem,headphones,heart pupils,historical,horns,horror,housewife,huge boobs,idol,impregnation,inseki,interview,inverted nipples,isekai,kimono,kogal,lactation,lingerie,love hotel,magical girl,maid,masturbation,miko,monster girl,muscles,music,netorare,netorase,netori,newhalf,ninja,nun,nurse,office lady,ojousama,ongoing,oni,orgasm denial,osananajimi,paizuri,pegging,petite,platformer,ponytail,pregnant,pubic hair,puzzle,qipao,rimjob,schoolgirl outfit,sci-fi,shimapan,slice of life,socks,spats,spread,squirting,stockings,subbed,succubus,swimsuit,swinging,tanlines,teacher,tomboy,toys,trans,tsundere,twintails,ugly bastard,uncensored,unlimited,vanilla,voyeurism,waitress,western,whiteout,x-ray,yandere,yaoi,yuri'.split(',')
const tagsData = await Promise.all(tags.map(v => fetchStatByTag(v).then(r => [v, r])))
const regionData = {}
for (const [ tag, regions ] of tagsData) {
for (const region in regions) {
const value = regions[region]
if (!regionData[region] || value > regionData[region][1]) {
regionData[region] = [ tag, value ]
}
}
}
console.table({ 'Регион': ['Самый популярный тэг', 'Показов в месяц'], ...regionData})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment