Comments (2)
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.
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)
- Scraper was working and now isn't
- The scraper returns no results HOT 10
- permission denied: tiktok-scraper HOT 1
- Get video captions HOT 1
- Unable to npm install HOT 5
- Bug: getUserProfileInfo method doesn't work for users with 0 posts
- Python scraper
- Can't Extract Video Metadata HOT 5
- is this amazing tool still working? HOT 3
- download videos as .mp4 files without watermarks
- Scraper HOT 1
- Can't extract video metadat HOT 2
- Scrape shop/product data HOT 1
- Enable running on Apify cloud platform
- o
- Docker run User fails even if user exists
- Failing to use terminal command when running on Windows 10
- Is this still working ? HOT 7
- Multiple Downloading HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tiktok-scraper.