Skip to content

Commit 05d77c6

Browse files
committed
update
1 parent b60dc90 commit 05d77c6

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
> **其他实战**
6666
67-
[企业名片查询](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【企业名片】企业查询) | [百度找回密码](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【百度】网页找回密码) | [美女壁纸下载](https://github.com/wkunzhi/Python3-Spider/tree/master/【双色球】头奖分布) | [美女壁纸下载](https://github.com/wkunzhi/Python3-Spider/tree/master/【壁纸】美女壁纸下载器) | [美团 解析与token生成](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【美团】数据解析、token生成) | [bilibili 视频下载](https://github.com/wkunzhi/Python3-Spider/tree/master/【bilibili】视频下载) | [51job 查岗位](https://github.com/wkunzhi/Python3-Spider/tree/master/【51Job】查岗位) | [百度 翻译](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【百度】翻译) | [美团 全国区域](https://github.com/wkunzhi/Python3-Spider/tree/master/各站案例/MeiTuanArea) | [企业名片查询](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【餐饮】查询信息) | [快递查询](https://github.com/wkunzhi/Python3-Spider/tree/master/【快递】单号查询) | [金逸电影 注册](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【金逸电影】自动注册) | [Python加密库Demo](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【Python加密库】Demo) | [百度街拍图片下载](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【百度街拍】图片下载) | [京东商品数据爬取](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【京东】商品数据爬取) | [房价获取](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【房价】房价获取)
67+
[抖音无水印视频解析](https://github.com/wkunzhi/Python3-Spider/tree/master/【抖音】无水印视频解析) | [企业名片查询](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【企业名片】企业查询) | [百度找回密码](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【百度】网页找回密码) | [美女壁纸下载](https://github.com/wkunzhi/Python3-Spider/tree/master/【双色球】头奖分布) | [美女壁纸下载](https://github.com/wkunzhi/Python3-Spider/tree/master/【壁纸】美女壁纸下载器) | [美团 解析与token生成](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【美团】数据解析、token生成) | [bilibili 视频下载](https://github.com/wkunzhi/Python3-Spider/tree/master/【bilibili】视频下载) | [51job 查岗位](https://github.com/wkunzhi/Python3-Spider/tree/master/【51Job】查岗位) | [百度 翻译](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【百度】翻译) | [美团 全国区域](https://github.com/wkunzhi/Python3-Spider/tree/master/各站案例/MeiTuanArea) | [企业名片查询](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【餐饮】查询信息) | [快递查询](https://github.com/wkunzhi/Python3-Spider/tree/master/【快递】单号查询) | [金逸电影 注册](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【金逸电影】自动注册) | [Python加密库Demo](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【Python加密库】Demo) | [百度街拍图片下载](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【百度街拍】图片下载) | [京东商品数据爬取](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【京东】商品数据爬取) | [房价获取](https://github.com/wkunzhi/Python3-Spider/tree/master/其他实战/【房价】房价获取)
6868

6969

7070

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
这是一份抖音无水印单个视频的解析代码
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- encoding: utf-8 -*-
2+
# Auth: Zok Email: [email protected]
3+
# Date: 2020/3/6
4+
+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# -*- encoding: utf-8 -*-
2+
# Auth: Zok Email: [email protected]
3+
# Date: 2020/3/6
4+
5+
import re
6+
import requests
7+
import json
8+
9+
10+
class ParseVideo:
11+
12+
def __init__(self, share):
13+
path = self.get_url(share)
14+
self.url = 'https://v.douyin.com/' + path + '/'
15+
self.headers = {
16+
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
17+
}
18+
self.session = requests.session()
19+
self.first_url = None
20+
21+
@staticmethod
22+
def get_url(share_url):
23+
return re.search(r'https://v\.douyin\.com/(.*?)/', share_url).group(1)
24+
25+
def go_location(self):
26+
response = self.session.get(self.url, headers=self.headers)
27+
self.first_url = response.url
28+
result = re.search(r'itemId: "(.*?)",[\s\S]*?uid: "(.*?)",[\s\S]*?authorName: "(.*?)",[\s\S]*?dytk: "(.*?)"',
29+
response.text)
30+
return result
31+
32+
def go_message(self, ret):
33+
url = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=' + ret.group(1) + '&dytk=' + ret.group(4)
34+
response = self.session.get(url, headers=self.headers)
35+
json_data = json.loads(response.text)
36+
user_id = ret.group(2)
37+
user_name = ret.group(3).encode('utf-8').decode('unicode_escape')
38+
39+
if json_data.get('status_code') != 0:
40+
print('解析失败')
41+
exit()
42+
item_list = json_data.get('item_list')[0]
43+
aweme_id = item_list.get('aweme_id')
44+
desc = item_list.get('desc')
45+
comment_count = item_list.get('statistics').get('comment_count')
46+
digg_count = item_list.get('statistics').get('digg_count')
47+
48+
video = item_list.get('video')
49+
cover = video.get('origin_cover').get('url_list')[0]
50+
play_addr = video.get('play_addr_lowbr').get('url_list')[0]
51+
52+
play_addr_response = self.session.get(play_addr, headers=self.headers, allow_redirects=False)
53+
msg = """
54+
用户id:{user_id}
55+
用户名:{user_name}
56+
作品id:{aweme_id}
57+
标题: {desc}
58+
评论数: {comment_count}
59+
点赞数: {digg_count}
60+
封面地址:{cover}
61+
无水印视频:{addr}
62+
""".format(
63+
user_id=user_id,
64+
user_name=user_name,
65+
aweme_id=aweme_id,
66+
desc=desc,
67+
comment_count=comment_count,
68+
digg_count=digg_count,
69+
cover=cover,
70+
addr=play_addr_response.headers['location']
71+
)
72+
print(msg)
73+
74+
def start(self):
75+
result = self.go_location()
76+
self.go_message(result)
77+
78+
79+
if __name__ == '__main__':
80+
# text = '#在抖音,记录美好生活#要逆天!北京地坛医院证实新冠病毒攻击中枢神经系统 https://v.douyin.com/tW7qrw/ 复制此链接,打开【抖音短视频】,直接观看视频!'
81+
text = input('请输入分享链接>>>')
82+
pv = ParseVideo(text)
83+
pv.start()

0 commit comments

Comments
 (0)