kyuurzy

The Hentai Search

Oct 8th, 2025 (edited)
72
0
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.55 KB | Source Code | 0 0
  1. const cheerio = require("cheerio")
  2.  
  3. async function thsearch(query) {
  4.   const baseUrl = 'https://en.thehentai.net';
  5.   const encodedQuery = encodeURIComponent(query.trim());
  6.   const url = baseUrl + '/?s=' + encodedQuery + '&utm_source=TheHentaiSearch&utm_medium=' + encodedQuery;
  7.  
  8.   const response = await fetch(url);
  9.   const html = await response.text();
  10.  
  11.   const $ = cheerio.load(html);
  12.  
  13.   const heading = $('h2').first().text().trim();
  14.   const resultsText = heading || '';
  15.  
  16.   const ads = [];
  17.   $('div[style*="display:flex; margin:20px 0;"]').each((i, elem) => {
  18.     let imgSrc = $(elem).find('img').attr('src') || null;
  19.     if (imgSrc && imgSrc.startsWith('/')) {
  20.       imgSrc = baseUrl + imgSrc;
  21.     }
  22.     ads.push({ imgSrc });
  23.   });
  24.  
  25.   const posts = [];
  26.   $('.gridPosts').each((i, elem) => {
  27.     const $post = $(elem);
  28.     const linkEl = $post.find('h3 a');
  29.     const href = linkEl.attr('href') || null;
  30.     const title = linkEl.attr('title') || null;
  31.  
  32.     let imgSrc = $post.find('div.img_cage img').attr('src') || null;
  33.     if (imgSrc && imgSrc.startsWith('/')) {
  34.       imgSrc = baseUrl + imgSrc;
  35.     }
  36.  
  37.     const viewsText = $post.find('.postViews').text().trim() || '';
  38.     const dateText = $post.find('.dataPost a').attr('title') || '';
  39.  
  40.     posts.push({
  41.       url: href ? baseUrl + href : null,
  42.       title,
  43.       imgSrc,
  44.       views: viewsText,
  45.       date: dateText
  46.     });
  47.   });
  48.  
  49.   return {
  50.     resultsText,
  51.     posts
  52.   };
  53. }
  54.  
  55. //use
  56. const ttk = await thsearch("marin kitagawa")
  57. console.log(JSON.stringify(ttk, null, 2));
Tags: Scrape
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment