2022-02-25 19:58:08 +01:00
2022-02-25 16:55:02 +01:00
2022-02-25 16:55:02 +01:00
2022-02-25 17:08:54 +01:00
2022-02-25 17:08:54 +01:00
2022-02-25 19:58:08 +01:00

TikTok hashtag analysis toolset

The tool helps to download posts and videos from tiktok for a given set of hashtags. It uses tiktok-scraper (https://github.com/drawrowfly/tiktok-scraper) to download the posts and videos.

Pre-requisites

  1. Make sure you have python 3.8 or later version installed.
  2. Download and install TikTok scraper: https://github.com/drawrowfly/tiktok-scraper

Options for running run_downloader.py

Screenshot 2022-02-25 at 19 04 26

Data organization

Screenshot 2022-02-25 at 19 21 44

data folder contains all the downloaded data as shown in the pic above.

  1. the log folder contains log.json which records the total number of downloaded posts and videos for the hashtags against the time stamp of when the script is run.
  2. the ids folder contains two files post_ids.json and video_ids.json that records the ids of the downloaded posts and videos for each hashtag.
  3. Each hashtag has a folder with two subfolders posts and videos that store posts and videos respectively. The posts are stored in the data.json file in the posts folder, and videos are stored as the .mp4 files in the videos folder.

Post download

Run the run_downloader.py with the following option: python3 run_downloader.py --h london paris newyork -p

Screenshot 2022-02-25 at 19 14 06
  1. The --h option allows to type in hashtag list in the commandline.
  2. -p option specifies the download posts option.

Video download

python3 run_downloader.py --h london -v

  1. --h option allows to type in the list of hashtags as command line argument.
  2. -v option is for downloading the videos The above code download all the trending videos for the hashtag london. Note that video downloading is a time and data rate consuming task, as a result we strongly recommend to use one hashtag at a time so as to avoid complications.

Top n hashtag occurrences

In the analytics folder, the file hashtag_frequencies.py will plot the frequencies of top occurring hashtags in a given set of posts. Assume we want to plot the graph of top 20 occurring hashtags in the downloaded posts of the hashtag london.

  1. Plotting the saving the image as a png file: python3 hashtag_frequencies.py -p ../data/london/posts/data.json 20 -v
Screenshot 2022-02-25 at 19 45 40

The figure above shows the top 20 occurring hashtags among all the posts downloaded for the hashtag london. Clearly, the highest occurrence will be of the hashtag london as the file data/london/posts/data.json contain all the posts with hashtag london.

  1. Printing the result in the shell: python3 hashtag_frequencies.py -d ../data/london/posts/data.json 20 -v Screenshot 2022-02-25 at 19 54 09

The same result of 1 is printed in the shell. The last column shows the ratio of the occurrence to the total posts.

Description
Provides tools to analyze hashtags within posts scraped from TikTok.
Readme MIT 290 KiB
Languages
Python 97%
Shell 2.1%
Dockerfile 0.9%