获取b站视频评论和子评论储存csv-以周菲戈我不相信为例
# 打开网页 抓取b站网页内容 保存为评论html 方法此处不再赘述

# 分析网页代码 找出储存评论的节点
# 评论 class='root-reply-container' .reply-content span
# 子评论 class='sub-reply-container' .reply-content span
from pyquery import PyQuery
import csv
with open('评论.html', 'r', encoding='utf-8') as fr:
html = fr.read()
doc = PyQuery(html)
div = doc('.root-reply-container')
span_list = div('.reply-content')
ls = []
for span in span_list.items():
ls.append(span.text())
div_2 = doc('.sub-reply-container')
ls2 = []
span_list_2 = div_2('.reply-content')
for span_2 in span_list_2.items():
ls2.append(span_2.text())

# 把评论储存为csv文件 虽然不知道为啥强迫自己要这样子存
with open('评论.csv', 'w', encoding='utf-8', newline='') as f:
writer = csv.writer(f)
header = "评论", "子评论"
writer.writerow(header)
for ls_1, ls_2 in zip(ls, ls2):
data = ''.join(ls_2)
writer.writerow([is_1]+[data])

# 今天是没有私货的一天,难受!

