爬虫- 爬取快手视频-批量爬取 | 视频解密AES-128
爬取快手视频代码:
import requests import json import re # 输入你想要的搜索关键词 key = input('输入你搜索的关键词:') # range(0, 3) -> 0 1 2 抓取, 3表示结束不抓取 for pcursor in range(0, 3): headers = { 'accept': '*/*', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Connection': 'keep-alive', 'Content-Length': '1279', 'content-type': 'application/json', 'Cookie': 'kpf=PC_WEB; kpn=KUAISHOU_VISION; clientid=3; did=web_e8ca87384bb99320873d4f0cdb8b4a0b', 'Host': 'www.kuaishou.com', 'Origin': 'https://www.kuaishou.com', 'Referer': 'https://www.kuaishou.com/search/video?searchKey=%E6%85%A2%E6%91%87', 'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"', 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': 'Windows', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36' } url = 'https://www.kuaishou.com/graphql' data = { "operationName": "visionSearchPhoto", "query": "fragment photoContent on PhotoEntity {\n id\n duration\n caption\n likeCount\n viewCount\n realLikeCount\n coverUrl\n photoUrl\n photoH265Url\n manifest\n manifestH265\n videoResource\n coverUrls {\n url\n __typename\n }\n timestamp\n expTag\n animatedCoverUrl\n distance\n videoRatio\n liked\n stereoType\n profileUserTopPhoto\n __typename\n}\n\nfragment feedContent on Feed {\n type\n author {\n id\n name\n headerUrl\n following\n headerUrls {\n url\n __typename\n }\n __typename\n }\n photo {\n ...photoContent\n __typename\n }\n canAddComment\n llsid\n status\n currentPcursor\n __typename\n}\n\nquery visionSearchPhoto($keyword: String, $pcursor: String, $searchSessionId: String, $page: String, $webPageArea: String) {\n visionSearchPhoto(keyword: $keyword, pcursor: $pcursor, searchSessionId: $searchSessionId, page: $page, webPageArea: $webPageArea) {\n result\n llsid\n webPageArea\n feeds {\n ...feedContent\n __typename\n }\n searchSessionId\n pcursor\n aladdinBanner {\n imgUrl\n link\n __typename\n }\n __typename\n }\n}\n", 'variables': {'keyword': key, 'pcursor': f"{pcursor}", 'page': "search",'searchSessionId': "MTRfMF8xNjUxNjY0MzM5NjI5X-aFouaRh184ODUz"} } # 将字典类型 转化 json字符串 data = json.dumps(data) resp = requests.post(url=url, headers=headers, data=data) # 拿到页面数据 字典格式 json_data = resp.json() #在字段中获取 值 lists = json_data["data"]["visionSearchPhoto"]["feeds"] for list in lists: # list 是个字典 获取视频的标题 title = list['photo']['caption'] # 去掉标题里面特殊字符 , 预防title 里面有特殊字符不能被系统识别 new_title = re.sub(r'[/\:*?"|\n]', '_', title) # 获取视频的地址 info_url = list['photo']['photoUrl'] # 保存视频 resp = requests.get(info_url).content with open('v/' + new_title + '.mp4', mode='wb') as f: f.write(resp) print('下载完成' + new_title)
2. AES -128 解密
2.1 需要安装包
pip install pycryptodome
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App