Usage

Make sure you have read section the first section on how to install the package.

API

class TiktokScraper(**kwargs)[source]

Instantiates TiktokScraper object used for gathering various Tiktok data

Variables:
  • user_agent (str) – Provide custom user_agent

  • proxies (List[str]) – Provide custom proxies

Returns:

Instantiated object

Return type:

TiktokScraper

get_comments(videos, limit_comments=50) List[Comment][source]

Scrape comments from a specific video. Provide video url(s) or video id(s)

Parameters:
  • videos (List[str]) – Provide video url(s) or video id(s). Can be a single string or list of strings

  • limit_comments (int) – Maximum amount of comments

Returns:

tiktokscraper.models.Comment

Return type:

list

get_followers_for_user(secUid, limit=5) List[Profile][source]

Return followers for user. Provide secUid and optional limit

Parameters:
  • secUid (str) – secUid

  • limit (int) – Limit number of followers

Returns:

List of Profiles

Return type:

list

async get_profile_details(profiles) List[Profile][source]

Scrape all information regarding a specific profile. Provide profile url(s) or username(s)

Parameters:

profiles (List[str]) – Provide profile url(s) or profile id(s). Can be a single string or list of strings

Returns:

tiktokscraper.models.Profile

Return type:

list

async get_trending_videos(limit_videos=10) List[Video][source]

Return video ids for current trending videos.

Returns:

List of video ids of trending videos

Return type:

list

async get_video_details(videos) List[Video][source]

Scrape all relevant details from a specific video. Provide video urls

Parameters:

videos (List[str]) – Provide video urls.

Returns:

tiktokscraper.models.Video

Return type:

list

async get_videos_for_keyword(keyword: str, limit=10) List[str][source]

Return video ids for a specific keyword.

Parameters:
  • keyword – Provide keyword

  • limit_videos (int) – Maximum amount of videos

Returns:

List of video ids for keyword

Return type:

list

async get_videos_of_user(user: str) List[Video][source]

Return all relevant video ids for a specific user. Provide username

Parameters:

user – Provide username

Returns:

List of videos of user

Return type:

list

Models

class Comment(**kwargs)[source]

Entails all relevant data concerning a specific comment

Variables:
  • comment_language (str) – Comment language

  • text (str) – Comment content

  • user_id (str) – Unique username

  • user_nickname (str) – User nickname (not unique)

  • create_time (datetime.datetime) – Create time

  • reply_comment_total (int) – Number of replies to the comment

  • reply_comment (List[Comment]) – Replies

class Profile(**kwargs)[source]

Entails all relevant data concerning a profile

Variables:
  • follower_count (int) – Follower count

  • following_count (int) – Following count

  • friend_count (int) – Friend count

  • heart (int) – Heart

  • heart_count (int) – Heart count

  • video_count (int) – Video count

  • commerce_user (bool) – Is commerce user True/False

  • nickname (str) – Nickname

  • private_account (bool) – Is private account True/False

  • signature (str) – Signature

  • verified (bool) – Is verified True/False

class Video(**kwargs)[source]

Entails all relevant data concerning a video

Variables:
  • video_id (str) – Video ID

  • description (str) – Description

  • create_time (int) – Creat time

  • is_pinned (bool) – Is pinned

  • music_author (str) – Music author name

  • music_id (str) – Music id

  • music_title (str) – Music title

  • music_url (str) – Music URL

  • collect_count (int) – Collect count

  • comment_count (int) – Comment count

  • digg_count (int) – Digg Count

  • play_count (int) – Play count

  • share_count (int) – Share count

  • download_url (str) – Download URL