0

I am using https://github.com/drawrowfly/tiktok-scraper/ to scrape some data. My code is

const TikTokScraper = require('tiktok-scraper');
a = (async () => {
    try {
        let videoMeta = await TikTokScraper.getVideoMeta('https://www.tiktok.com/@nishaguragain/video/6823736724821216513');
        return videoMeta
    } catch (error) {
        console.log(error);
    }
})();

I am getting this after running the function.

    > a
Promise {
  { id: '6823736724821216513',
    text:
     'Bina bataye  video start kar diya😀#@deepakjoshi.102 #stayhome #foryou #nishaguragainfam',
    createTime: '1588775017',
    authorMeta: { id: '242395344267849728', name: 'nishaguragain' },
    musicMeta:
     { musicId: '6595720952414210822',
       musicName: 'I nerver thought she could dance like this',
       musicAuthor: 'flighthouse' },
    imageUrl:
     'https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/47436416b93b4cd1ac0b7ed0c17c6ba3_1588775020?x-expires=1598338800&x-signature=KvfbQJwk0jCmNaJwKeae719duq4%3D',
    videoUrl:
     'https://v16m.tiktokcdn.com/240a38ca388d5f719e0998bc625a77e8/5f44be52/video/tos/useast2a/tos-useast2a-ve-0068c001/cbbcb564b09a4c66a58fe8365a98b99b/?a=1233&br=7528&bt=3764&cr=0&cs=0&dr=0&ds=3&er=&l=2020082307313001011603423405001013&lr=tiktok_m&mime_type=video_mp4&qs=0&rc=ajxxM3l1czNmdDMzODczM0ApNDk3ZzZnZGRmNzplaDc4PGdlYi9nZmNkZG1fLS0zMTZzczA2MS1iMTQ2XzMxXmMzL2E6Yw%3D%3D&vl=&vr=',
    videoUrlNoWaterMark:
     'https://api2-16-h2.musical.ly/aweme/v1/play/?video_id=v09044650000bqpcg0gpfrivj02ne9hg&vr_type=0&is_play_url=1&source=PackSourceEnum_PUBLISH&media_type=4',
    videoMeta: { width: 540, height: 960, ratio: 13, duration: 13 },
    covers:
     { default:
        'https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/41374d9703a34cbb82e61c2fccf3d36c_1588775020?x-expires=1598338800&x-signature=M%2FlqnSTqPPF%2BxBj%2BZqZNmg7wmBM%3D',
       origin:
        'https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/47436416b93b4cd1ac0b7ed0c17c6ba3_1588775020?x-expires=1598338800&x-signature=KvfbQJwk0jCmNaJwKeae719duq4%3D' },
    diggCount: 938500,
    shareCount: 2649,
    playCount: 10600000,
    commentCount: 2213,
    downloaded: false,
    mentions: [ '@deepakjoshi' ],
    hashtags: [ [Object], [Object], [Object] ] } }

How can i get value of imageUrl: that is https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/47436416b93b4cd1ac0b7ed0c17c6ba3_1588775020?x-expires=1598338800&x-signature=KvfbQJwk0jCmNaJwKeae719duq4%3D in a variable to use in future.

When i am typing videoMeta it is showing Thrown: ReferenceError: videoMeta is not defined videoMeta is not defined

Screenshot

4
  • Maybe unfair this question was closed against those particular answers, if it relates to the NodeJS REPL. However it wasn't stated if solving it in the REPL was the aim. The linked answers should solve the problem for script code, but for REPL code you might want to use the --experimental-repl-await flag when launching the Node REPL. This will permit you to easily get the resolved value from a promise using a 'top level' await in the REPL. See nodejs.org/api/repl.html#repl_await_keyword for more information. Commented Aug 23, 2020 at 12:07
  • None of the above post helps me in my situation. Commented Aug 23, 2020 at 16:27
  • Sorry to hear that, Habib. Are you comfortable with what the await keyword does and how it relates to a Promise ? A Promise is a wrapper around a future value. When the value finally arrives, you still have to unwrap it, which is what await does. So for example in the context of your REPL you would be able to type resolvedA = await a; resolvedA.videoMeta . However, to do this in the Node REPL, you have to launch node with explicit support for being able to use the await keyword interactively. Commented Aug 23, 2020 at 17:19
  • At that time, I was a beginning my journey in Javascript. Thank You for your response. I got mysef enrolled for the JS course and leraned too many new things(Keywords). Commented Jan 9, 2022 at 7:58

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.