Downloading Douyin (TikTok) Videos Without Watermark Using Python and JSONPath
This article explains a simplified Python method for extracting and downloading watermark‑free Douyin videos by inspecting network requests, using the jsonpath library, and automating the download process with concise code, while also discussing its advantages and current limitations.
The author presents a more straightforward approach to obtain Douyin short videos compared with a previous URL‑construction method, by directly inspecting the network XHR requests of a Douyin user page and extracting the hidden video URLs.
Using the browser's developer tools, one can locate the preview tab, then follow video → download_addr → url_list to find the actual video links, which include both watermarked and watermark‑free versions.
The implementation relies on the jsonpath Python module (installable via pip install jsonpath ) to parse the JSON response and retrieve the play_addr field that contains the no‑watermark URL.
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('Downloading:', 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 main advantages of this method are the reduction of URL‑analysis steps, no reliance on WebDriver or a specific browser, faster execution, and the ability to download videos without watermarks.
However, the approach still requires manually handling a randomly generated signature string, making the process somewhat cumbersome and not fully automated.
To run the script, install the required library, execute the Python file, and the videos will be saved locally under the specified directory.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.