Skip to content

Commit

Permalink
🌝更新用户主页接口 #241 #263 #264 #266 #269 #271 #272 #273 #275 #276 #278 #279 #…
Browse files Browse the repository at this point in the history
…280 #281

不是最终更新版本,仅为最低可用版本。
  • Loading branch information
Johnserf-Seed committed Jan 14, 2023
1 parent fc69333 commit f8a3fcf
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions Util/Profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

import Util

############apis############
# /aweme/v1/web/aweme/detail/ 'aweme_detail'
# /aweme/v1/web/aweme/post/ 'aweme_list'
###########################

class Profile():

def __init__(self):
Expand All @@ -25,10 +30,8 @@ def __init__(self):
self.max_cursor = 0
# 全局IOS头部
self.headers = Util.headers

# 系统分隔符
self.sprit = Util.sprit

# 输出日志
Util.log.info(Util.platform.system())

Expand Down Expand Up @@ -68,9 +71,15 @@ def getProfile(self, param):
# 输出日志
Util.log.info('[ 提示 ]:用户的sec_id=%s' % self.sec)

post_url = 'https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid=%s&count=35&max_cursor=0&aid=1128&_signature=PDHVOQAAXMfFyj02QEpGaDwx1S&dytk=' % (
# 旧接口于22/12/23失效
# post_url = 'https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid=%s&count=35&max_cursor=0&aid=1128&_signature=PDHVOQAAXMfFyj02QEpGaDwx1S&dytk=' % (
# self.sec)
# 23/1/11
# 暂时使用不需要xg的接口
post_url = 'https://www.iesdouyin.com/aweme/v1/web/aweme/post/?sec_user_id=%s&count=35&max_cursor=0&aid=1128' % (
self.sec)
post_name_json = Util.json.loads(Util.requests.get(url = post_url, headers=self.headers).content.decode())
post_name_json = Util.json.loads(Util.requests.get(
url=post_url, headers=self.headers).content.decode())
# 2022/09/05
# 因为抖音页面分离技术,最初获取的网页信息没有经过js渲染,无法获取like模式下的用户名,故均用post模式获取用户名
try:
Expand All @@ -90,8 +99,12 @@ def getProfile(self, param):
exit()

# 构造第一次访问链接
self.api_post_url = 'https://www.iesdouyin.com/web/api/v2/aweme/%s/?sec_uid=%s&count=%s&max_cursor=%s&aid=1128&_signature=PDHVOQAAXMfFyj02QEpGaDwx1S&dytk=' % (
self.mode, self.sec, 35, self.max_cursor)
if self.mode == 'post':
self.api_post_url = 'https://www.iesdouyin.com/aweme/v1/web/aweme/post/?sec_user_id=%s&count=%s&max_cursor=%s&aid=1128' % (
self.sec, 35, self.max_cursor)
else:
self.api_post_url = 'https://www.iesdouyin.com/web/api/v2/aweme/like/?sec_uid=%s&count=%s&max_cursor=%s&aid=1128' % (
self.sec, 35, self.max_cursor)

# 创建用户文件夹
self.path = "." + self.sprit + "Download" + self.sprit + \
Expand Down Expand Up @@ -161,8 +174,13 @@ def getNextData(self):
"""获取下一页api数据
"""
# 构造下一次访问链接
api_naxt_post_url = 'https://www.iesdouyin.com/web/api/v2/aweme/%s/?sec_uid=%s&count=%s&max_cursor=%s&aid=1128&_signature=RuMN1wAAJu7w0.6HdIeO2EbjDc&dytk=' % (
self.mode, self.sec, 35, self.max_cursor)
# https://www.iesdouyin.com/aweme/v1/web/aweme/post/
if self.mode == 'post':
api_naxt_post_url = 'https://www.iesdouyin.com/aweme/v1/web/aweme/post/?sec_user_id=%s&count=%s&max_cursor=%s&aid=1128' % (
self.sec, 35, self.max_cursor)
else:
api_naxt_post_url = 'https://www.iesdouyin.com/web/api/v2/aweme/like/?sec_uid=%s&count=%s&max_cursor=%s&aid=1128' % (
self.sec, 35, self.max_cursor)

index = 0
result = []
Expand Down Expand Up @@ -216,7 +234,7 @@ def getVideoInfo(self, result):
# url_list < 4 说明是图集
# 2022/11/27 aweme_type是作品类型 2:图集 4:视频
if result[v]['aweme_type'] == 2:
#if len(result[v]['video']['play_addr']['url_list']) < 4:
# if len(result[v]['video']['play_addr']['url_list']) < 4:
self.image_list.append(result[v]['aweme_id'])
else:
self.author_list.append(str(result[v]['desc']))
Expand Down Expand Up @@ -256,8 +274,9 @@ def getVideoInfo(self, result):
return # self,author_list,video_list,uri_list,aweme_id,nickname,max_cursor

def s_homepage(self):
with open(self.path + self.sprit + self.nickname + '.txt','w') as f:
with open(self.path + self.sprit + self.nickname + '.txt', 'w') as f:
f.write(self.homepage)


if __name__ == '__main__':
Profile()

0 comments on commit f8a3fcf

Please sign in to comment.