This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const res = await axios.get( | |
"https://api.scrapecreators.com/v2/tiktok/video?url=https://www.tiktok.com/@stoolpresidente/video/7552934044887944478", | |
{ | |
headers: { | |
"x-api-key": process.env.MY_API_KEY, | |
}, | |
} | |
); | |
const rawVideo = res?.data?.aweme_detail?.video?.play_addr?.url_list?.[0]; | |
console.log("rawVideo", rawVideo); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
import { createClient } from '@supabase/supabase-js'; | |
const SUPABASE_URL = process.env.SUPABASE_URL; | |
const SUPABASE_KEY = process.env.SUPABASE_KEY; | |
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY); | |
const filePath = 'video.mp4'; | |
const bucket = 'videos'; // change to your bucket | |
const storagePath = `uploads/${filePath}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const languageMenu = findKey(transcriptRes, "languageMenu"); | |
console.log("languageMenu", languageMenu); | |
const language = | |
languageMenu?.sortFilterSubMenuRenderer?.subMenuItems?.[0]?.title?.split( | |
" " | |
)?.[0]; | |
const transcriptRenderer = findKey(transcriptRes, "transcriptRenderer") | |
?.content?.transcriptSearchPanelRenderer?.body?.transcriptSegmentListRenderer?.initialSegments?.map( | |
(tr) => tr?.transcriptSegmentRenderer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as cheerio from "cheerio"; | |
function jsonifyDuckDuckGo(html) { | |
try { | |
const $ = cheerio.load(html); | |
const results = []; | |
$(".results_links") | |
.get() | |
.forEach((result) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to recursively search for the key | |
export function findKey(obj, keyToFind) { | |
try { | |
if (obj.hasOwnProperty(keyToFind)) { | |
return obj[keyToFind]; | |
} | |
for (let key in obj) { | |
if (typeof obj[key] === "object" && obj[key] !== null) { | |
let result = findKey(obj[key], keyToFind); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"success": true, | |
"categories": [ | |
{ | |
"category_id": "700645", | |
"level": 1, | |
"is_leaf": false, | |
"parent_id": "0", | |
"category_name": "Saúde", | |
"name_key": "magellan_700645" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fudgeFactor = -6; | |
const captchaResponse = await solveCaptcha(puzzleImageUrl, pieceImageUrl); | |
console.log("captchaResponse", captchaResponse); | |
await dragElementHorizontal( | |
page, | |
".secsdk-captcha-drag-icon", | |
captchaResponse.slideXProportion * puzzleWidth + fudgeFactor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function fetchAndEncodeImage(url) { | |
const response = await axios.get(url, { responseType: "arraybuffer" }); | |
return Buffer.from(response.data, "binary").toString("base64"); | |
} | |
async function solveCaptcha(puzzleImageUrl, pieceImageUrl) { | |
try { | |
const puzzleBase64 = await fetchAndEncodeImage(puzzleImageUrl); | |
const pieceBase64 = await fetchAndEncodeImage(pieceImageUrl); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puzzleImage = await page.$("#captcha-verify-image"); | |
const puzzleImageUrl = await puzzleImage.evaluate((el) => el.src); | |
console.log("puzzleImageUrl", puzzleImageUrl); | |
const pieceImage = await page.$(".captcha_verify_img_slide"); | |
const pieceImageUrl = await pieceImage.evaluate((el) => el.src); | |
console.log("pieceImageUrl", pieceImageUrl); | |
const elementHandle = await page.$(".captcha_verify_img--wrapper"); | |
const box = await elementHandle.boundingBox(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:20-bullseye | |
# Install Chrome and xvfb | |
RUN apt-get update && apt-get install -y \ | |
chromium \ | |
xvfb \ | |
&& rm -rf /var/lib/apt/lists/* | |
WORKDIR /usr/src/app |
NewerOlder