Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INSTALLATION] - I managed to run my script perfectly! but seems that we are stuck with webpage limit? #1166

Open
vagvalas opened this issue Jun 24, 2024 · 0 comments
Labels
installation_help Someone is having problems installing the api

Comments

@vagvalas
Copy link

Please first check the closed issues on GitHub for people with similar problems to you.
If you'd like more instant help from the community consider joining the discord

I had overcome headless=false on macOS , i modify my script using a help here and chat's gpt but even its working perfect and fetching ALL videos from a hashtag, it seems that only fetches 45-50 videos, (every-time the same) as i browse in the webpage https://tiktok.com/tag/.... and i can also see these videos.
The point is that even if i logged in, and inject cookie again from browser only this amount can be fetched?
Am i missing something?
So only through app can we get more? Is there any workaround?

Put the error trace below if there's any error thrown.

from TikTokApi import TikTokApi
from yt_dlp import YoutubeDL
import asyncio
import os

ms_token = os.environ.get("multi_sids", None)
ydl_opts = {
    'outtmpl': '%(uploader)s_%(id)s_%(timestamp)s.%(ext)s',
}

async def download_hashtag_videos(hashtag):
    async with TikTokApi() as api:
        await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3,
                                  headless=False, suppress_resource_load_types=["image", "media", "font", "stylesheet"])

        tag = api.hashtag(name=hashtag)
        cursor = 0

        while True:
            try:
                videos = tag.videos(count=100, cursor=cursor)
                fetched_any = False
                async for video in videos:
                    fetched_any = True
                    video_url = f"https://www.tiktok.com/@{video.author.username}/video/{video.id}"
                    print(video_url)
                    with YoutubeDL(ydl_opts) as ydl:
                        ydl.download([video_url])
                if not fetched_any:
                    break
                cursor += 100  # or use the next cursor value provided in the response
            except Exception as e:
                print(f"An error occurred: {e}")
                break

if __name__ == "__main__":
    hashtag = 'coldplayathens'
    asyncio.run(download_hashtag_videos(hashtag))

  • OS: [e.g. macOS 11.7.10]
  • TikTokApi Version [e.g. 6.3.0] - if out of date upgrade before posting an issue
@vagvalas vagvalas added the installation_help Someone is having problems installing the api label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation_help Someone is having problems installing the api
Projects
None yet
Development

No branches or pull requests

1 participant