Skip to content

Commit

Permalink
add random tiktok videos with username
Browse files Browse the repository at this point in the history
  • Loading branch information
thoriqazzikraa committed Nov 21, 2023
1 parent 6ba7842 commit fd06cbd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const scrape = require("scrape-websitee")
waifu,
shinobu
},

truthOrDare,
getCerpen,
getCerpenHorror,
randomTiktok
},
ai: {
textToImage, // (query)
},
Expand Down
2 changes: 1 addition & 1 deletion function/pickRandom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const pickRandom = async (ext) => {
const pickRandom = (ext) => {
return ext[Math.floor(Math.random() * ext.length)]
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrape-websitee",
"version": "1.0.57",
"version": "1.0.58",
"description": "Website Scraping",
"main": "index.js",
"scripts": {
Expand Down
31 changes: 30 additions & 1 deletion src/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@ const cheerio = require("cheerio")
const baseCerpen = "http://cerpenmu.com/100-cerpen-kiriman-terbaru"
const { pickRandom } = require("../function/pickRandom.js")

async function randomTiktok(username) {
let result = {}
if (!username.startsWith("@")) {
var user = "@" + username
} else {
var user = username
}
const { data } = await axios.get(`https://tiktok-video-no-watermark2.p.rapidapi.com/user/posts?unique_id=${user}&count=1000`, {
headers: {
Accept: "application/json",
"X-RapidAPI-Key": "533115be6amsh2515f73f171c6f1p160d9djsn833294e42f10",
"X-RapidAPI-Host": "tiktok-video-no-watermark2.p.rapidapi.com",
"User-Agent": "PostmanRuntime/7.32.2",
Referer: "https://tik.storyclone.com/"
}
})
if (data.code != 0) {
result.status = false
result.message = "Tidak dapat menemukan akun"
console.log(result)
return result
}
result.status = true
result.data = pickRandom(data.data.videos)
console.log(result.status)
return result
}

const listCerpen = async () => {
const { data } = await axios.get(baseCerpen)
let result = []
Expand Down Expand Up @@ -151,5 +179,6 @@ module.exports = {
},
truthOrDare,
getCerpen,
getCerpenHorror
getCerpenHorror,
randomTiktok
}

0 comments on commit fd06cbd

Please sign in to comment.