Crawler:基于requests库+urllib3库+伪装浏览器实现爬取抖音账号的信息数据
Crawler:Python之Crawler爬取抖音账号的信息数据
输出结果
更新……
代码设计
from contextlib import closing
import requests, json, time, re, os, sys, time
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
headers = {
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9',
'cache-control': 'max-age=0',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Linux; U; Android 5.1.1; zh-cn; MI 4S Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.146 Mobile Safari/537.36 XiaoMi/MiuiBrowser/9.1.3',
}
class DouYin(object):
def __init__(self, width=500, height=300):
"""
抖音App视频下载
"""
# 无头浏览器
chrome_options = Options()
chrome_options.add_argument(
def get_video_urls(self, user_id):
"""
获得视频播放地址
Parameters:
user_id:查询的用户ID
Returns:
video_names: 视频名字列表
video_urls: 视频链接列表
nickname: 用户昵称
"""
def video_downloader(self,video_urls, video_names, watermark_flag=False):
for i in range(len(video_urls)):
try:
video_url = video_urls[i]
def run(self):
user_id = input('请输入ID(例如108561773):')
if __name__ == '__main__':
douyin = DouYin()
douyin.run()
赞 (0)