标签:packages mac app find shared lun esc version als
import requests import re import os from glom import * def get_video(url): requests.packages.urllib3.disable_warnings() session = requests.session() headers = {‘User-Agent‘: ‘Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1‘} res = session.get(url=url, headers=headers, verify=False) seu_udi = re.findall(r‘sec_uid=(\w+-\w+-\w+|\w+-\w+|\w+)‘, res.url) sum_url = ‘https://www.iesdouyin.com/web/api/v2/user/info/?sec_uid={0}‘.format(seu_udi[0]) se = session.get(sum_url).json() video_count = glom(se, ‘user_info.aweme_count‘) nickname = glom(se, ‘user_info.nickname‘) short_id = glom(se, ‘user_info.short_id‘) print("nickname:%s" % nickname) print("video_count:%s" % video_count) with open(f‘{short_id}-{nickname}.txt‘, ‘wt‘) as f: f.write("nickname: "+nickname+"\n") f.write("short_id: "+short_id+"\n") max_cursor = 0 id = 0 w2 = 0 while True: while True: if (max_cursor == 0): sec_id_url = "https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid={0}&count=21&max_cursor=0&aid=1128&_signature=dF8skQAAK0iTKNSXi9av.XRfLI&dytk=".format( seu_udi[0]) else: sec_id_url = "https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid={0}&count=21&max_cursor={1}&aid=1128&_signature=dF8skQAAK0iTKNSXi9av.XRfLI&dytk=".format( seu_udi[0], max_cursor) sec_respone = session.get(url=sec_id_url, headers=headers, verify=False) comment = sec_respone.json() if (len(comment[‘aweme_list‘]) == 0): w2 += 1 if w2 >= 1: break continue else: break
max_cursor = comment[‘max_cursor‘] for s in comment[‘aweme_list‘]: id += 1 desc = s[‘desc‘] text = s[‘aweme_id‘] dianzan = s[‘statistics‘]["digg_count"] pinglun = s[‘statistics‘]["comment_count"] fenxiang = s[‘statistics‘]["share_count"] video_url = s[‘video‘][‘play_addr_lowbr‘][‘url_list‘][0] with open(f‘{short_id}-{nickname}.txt‘, ‘a‘) as f: f.write(str(dianzan)+","+str(fenxiang)+","+video_url+"\n") print(str(id) +"/"+ str(video_count) + ",{0},点赞:{1},评论:{2},分享:{3} {4}".format(text, str(dianzan), str(pinglun),str(fenxiang), desc)) est = requests.get(url=video_url, headers=headers) if not os.path.exists(short_id+‘-‘+nickname): os.mkdir(short_id+‘-‘+nickname) with open(f‘{short_id}-{nickname}/{dianzan}-{text}.mp4‘, ‘wb‘) as f: f.write(est.content) if(int(id) >= int(video_count)): break if __name__ == ‘__main__‘: url = input("input shared url:") get_video(url)
标签:packages mac app find shared lun esc version als
原文地址:https://www.cnblogs.com/nlsoft/p/14461441.html