Technology Sharing

Python crawler to get video

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Verify that Python is installed on your computer

1.Win+r input cmd

2. Enter in the black window

python.exe

3. If the command does not exist, it means that the Python environment is installed successfully.

Capture Kuaishou videos

1. Create a new project in the phcharm application

3. Create a new python file

4. Select the python file, give it a random name and press Enter

5. Install requests

pip install requests

6. Find the video you need

6.1 Open Kuaishou official website

                      Short video platform

6.2 Find your favorite video

6.3 Open the developer tools window by pressing the F12 shortcut key

6.4 Select Network, Select Media

6.5 Refresh the page and you can see two more pieces of data

6.6 Open data copy url

https://v2.kwaicdn.com/ksc2/dmEpeD04WisrxlETR9tltddmNMeCv4Q3RJ9boh_LBfbUF9J4a1UAlzhiLzZTqmdC0f6pG4-3xfHcJF6z-n-OcL4F-yvA0hjtgDwzH5EQOxU1yoWR0W0DxMeJEBknjq6nMKT3akEai3T1c3YSo1nIdmlQd-sOBncaeRW9uVnr9MBnSOcQujrHILNxCicpssi0.mp4?pkey=AAWKEWhsUbPgdevQuk5oKfzc-Vg9l94T_jXe7bxv2Qjui3JD0UG7Nq4wFqBCGhH0v66KYL63ZVal9_yP2HgGNAqlxItntrurnWiIGLz1CMoSw92cju9-CYmpaik4hg1sD4Q&tag=1-1720259808-unknown-0-67cgnxislq-a8b6825176192501&clientCacheKey=3xknmqjgx93kx5g_b.mp4&di=abd6d608&bp=10004&tt=b&ss=vp

7. Enter the following code and change the URL to your own video address

  1. # 视频网址
  2. url = ""
  3. # 导入请求模块
  4. import requests
  5. # 获取响应res
  6. res = requests.get(url)
  7. # print("响应码"+res.status_code) #响应码
  8. #
  9. # print("响应的内容"+res.content) #相应的内容
  10. open("青雀被奖励.mp4","xb").write(res.content)

8. Right click to open and view the video