Giter VIP home page Giter VIP logo

Comments (2)

apk015 avatar apk015 commented on June 10, 2024 1

this the of file that i run

**`import asyncio
import os
from TikTokApi import TikTokApi

async def fetch_trending_videos():
async with TikTokApi() as api:
# Initialize the TikTokApi object with your ms_token
ms_token = "Mp6Hs8_h3-Hx3wQe7fdCsDtpjcnS5PzqGRHoupINjcXZqW_KaV-qDOHKXflqPMpwJ6j-wrIG2Z2hSLHIjS1l8KSJXKxnin58hVTiFlEpGSm61T_wEEKtwwCjFt2NHlNC9Qct0lCb42dWPzU="

    # Create sessions with the ms_token
    await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3)

    # Initialize the counter
    counter = 0

    # Get trending videos
    async for video in api.trending.videos(count=100):
        counter += 1  # Increment the counter
        print(f"Video {counter} URL: https://www.tiktok.com/@{video.author.username}/video/{video.id}")

    print(f"Total number of URLs scraped: {counter}")

if name == "main":
asyncio.run(fetch_trending_videos())

`**

from tiktok-scraper.

jordancoxi avatar jordancoxi commented on June 10, 2024 1

It looks like you're encountering an error related to the Tiktok Audio extractor API in your Python script. The error message indicates that there's an issue with the TikTokException.init() method, specifically that it's missing two required positional arguments: 'raw_response' and 'message'.

Check the TikTok API Documentation:
Ensure that you are using the correct methods and parameters according to the latest version of the TikTok API. API libraries may change, and it's possible that there have been updates since you initially wrote or obtained your code.

Update TikTok API Library:
If you're using a third-party TikTok API library, make sure it's up-to-date. You can usually update it using the package manager (e.g., pip). For example:
pip install --upgrade TikTokApi
Review Your Code:
Double-check your code to ensure that you are correctly handling exceptions and that you are using the API in a way that aligns with the library's documentation.

Here's a basic example of how you might structure your code to catch and handle exceptions:
`from TikTokApi import TikTokApi, TikTokException

async def fetch_trending_videos():
api = TikTokApi()
try:
async for video in api.trending.videos(count=100):
# Process each video
print(video)
except TikTokException as e:
print(f"Error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")

asyncio.run(fetch_trending_videos())`
Make sure your code is compatible with the current version of the library.

from tiktok-scraper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.