Backend Development 4 min read

Extracting Douyin (TikTok) Video URLs Without Watermark Using Python and jsonpath

This article demonstrates a simpler method to obtain water‑marked‑free Douyin video URLs by inspecting network requests, extracting hidden links, and using a Python script with the jsonpath library to download videos directly, highlighting advantages and remaining limitations.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Extracting Douyin (TikTok) Video URLs Without Watermark Using Python and jsonpath

The author revisits a previous blog about constructing URLs to fetch Douyin short videos and presents a much simpler approach that avoids many analysis steps. By opening a Douyin user page, inspecting the Network tab under the XHR filter, and locating the preview section, the hidden video URLs can be directly extracted.

Two key URLs are found under video → download_addr → url_list and play_addr , which point to the actual video files without watermarks. The method requires patience to locate these deep‑nested links but eliminates the need for complex URL construction.

To automate the extraction, the jsonpath module is installed via pip install jsonpath . The following Python script demonstrates the full workflow: it builds the request URL, sends a GET request with appropriate headers, parses the JSON response, uses jsonpath to locate the paly_addr field, selects the second URL in the url_list , downloads the video content, and saves it locally.

pip install jsonpath
import requests
import json
import jsonpath

class Douyin:
    def page_num(self, max_cursor):
        random_field = '00nvcRAUjgJQBMjqpgesfdNJ72&dytk=4a01c95562f1f10264fb14086512f919'
        url = ('https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid=MS4wLjABAAAAU7Bwg8WznVaafqWLyLUwcVUf9LgrKGYmctJ3n5SwlOA'
               '&count=21&max_cursor=' + str(max_cursor) + '&aid=1128&_signature=' + random_field)
        headers = {
            'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36',
        }
        response = requests.get(url, headers=headers).text
        resp = json.loads(response)
        max_cursor = resp['max_cursor']
        for data in resp['aweme_list']:
            video_title = data['desc']
            video_url = jsonpath.jsonpath(data, '$..paly_addr')
            for a in video_url:
                video_realurl = a['url_list'][1]
            video = requests.get(video_realurl, headers=headers).content
            with open('t/' + video_title, 'wb') as f:
                print('正在下载:', video_title)
                f.write(video)
        if max_cursor == 0:
            return 1
        else:
            self.page_num(max_cursor)

if __name__ == '__main__':
    douyin = Douyin()
    douyin.page_num(max_cursor=0)

The script’s advantages include removing most URL‑construction steps, not requiring a WebDriver (thus no browser constraints), and achieving faster downloads of watermark‑free videos. However, it still relies on a hard‑coded random string and the overall process can be cumbersome.

PythonAPIJsonPathWeb ScrapingVideo DownloadDouyin
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.