Advertisement
WILDAN_IZZUDIN

[JS] JALANTIKUS SCRAPER

Jan 3rd, 2022 (edited)
1,113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let axios = require('axios')
  2. let cheerio = require('cheerio')
  3.  
  4. function quotenime() {
  5.     return new Promise(async(resolve) => {
  6.     try {
  7.         let html = await (await axios.get('https://jalantikus.com/hiburan/kata-kata-anime/')).data
  8.         let $ = cheerio.load(html)
  9.         let data = []
  10.         $('div.li-wrapper').each((i,e) => $(e).text().startsWith('"') ? data.push($(e).text()) : '')
  11.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: true, data })
  12.     } catch (e) {
  13.         console.log(e)
  14.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: false })
  15.     }})
  16. }
  17.  
  18. function ultah() {
  19.     return new Promise(async(resolve) => {
  20.     try {
  21.         let html = await (await axios.get('https://jalantikus.com/quotes/ucapan-ulang-tahun-untuk-sahabat/')).data
  22.         let $ = cheerio.load(html)
  23.         let data = []
  24.         $('code').each((i,e) => data.push(/Terjemahan/.test($(e).text()) ? $(e).text().split('Terjemahan:')[1].trim() : $(e).text()))
  25.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: true, data })
  26.     } catch (e) {
  27.         console.log(e)
  28.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: false })
  29.     }})
  30. }
  31.  
  32. function tebakan() {
  33.     return new Promise(async(resolve) => {
  34.     try {
  35.         let html = await (await axios.get('https://jalantikus.com/quotes/tebak-tebakan-lucu-terbaru/')).data
  36.         let $ = cheerio.load(html)
  37.         let data = [], answer = []
  38.         let ans = html.split('Jawaban:')
  39.         for (let i=0; i<ans.length; i++) if (i != '95') answer.push(ans[i].split('</p>')[0].replace(/<\/strong>|<em>|<\/em>/g, '').trim())
  40.         $('div.li-wrapper').each((i,e) => !$(e).text().startsWith('\r') ? data.push({ soal: $(e).text(), jawaban: answer[i - 9] }) : '')
  41.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: true, data })
  42.     } catch (e) {
  43.         console.log(e)
  44.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: false })
  45.     }})
  46. }
  47.  
  48. function gombal() {
  49.     return new Promise(async(resolve) => {
  50.     try {
  51.         let html = await (await axios.get('https://jalantikus.com/quotes/gombalan-bikin-baper/')).data
  52.         let $ = cheerio.load(html)
  53.         let data = []
  54.         $('div.li-wrapper').each((i,e) => $(e).text().startsWith('"') && !/(Cowok|Cewek):/.test($(e).text()) ? data.push($(e).text()) : '')
  55.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: true, data })
  56.     } catch (e) {
  57.         console.log(e)
  58.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: false })
  59.     }})
  60. }
  61.  
  62. function motivasi() {
  63.     return new Promise(async(resolve) => {
  64.     try {
  65.         let html = await (await axios.get('https://jalantikus.com/quotes/kata-motivasi-hidup/')).data
  66.         let $ = cheerio.load(html)
  67.         let data = []
  68.         $('div.li-wrapper').each((i,e) => $(e).text().startsWith('"') ? data.push($(e).text()) : '')
  69.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: true, data })
  70.     } catch (e) {
  71.         console.log(e)
  72.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: false })
  73.     }})
  74. }
  75.  
  76. function gokil() {
  77.     return new Promise(async(resolve) => {
  78.     try {
  79.         let html = await (await axios.get('https://jalantikus.com/tips/kata-kata-lucu/')).data
  80.         let $ = cheerio.load(html)
  81.         let data = []
  82.         $('div.li-wrapper').each((i,e) => !$(e).text().startsWith('\r') ? data.push($(e).text()) : '')
  83.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: true, data })
  84.     } catch (e) {
  85.         console.log(e)
  86.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: false })
  87.     }})
  88. }
  89.  
  90. function captionIg() {
  91.     return new Promise(async(resolve) => {
  92.     try {
  93.         let html = await (await axios.get('https://jalantikus.com/tips/caption-instagram-kekinian/')).data
  94.         let $ = cheerio.load(html)
  95.         let data = []
  96.         $('div.li-wrapper').each((i,e) => !$(e).text().startsWith('\r') ? data.push($(e).text()) : '')
  97.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: true, data })
  98.     } catch (e) {
  99.         console.log(e)
  100.         return resolve({ creator: '@neoxrs – Wildan Izzudin', status: false })
  101.     }})
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement