|
发表于 2020-9-18 15:05:31
|
显示全部楼层
好多不懂:
请大神指教
1:
tags = video.select("div[class='tags'] > span") 这个是什么意思?select是一种什么方法?
for tag in tags:
datas.append(''.join(tag.text.split())) 这个更不懂?空格后的.点的方法是join?内部还有带切片?
2:
"s -> (s0,s1,s2,...sn-1), (sn,sn+1,sn+2,...s2n-1), (s2n,s2n+1,s2n+2,...s3n-1), ..."
return zip(*[iter(iterable)]*n) 这个直接懵逼,怎么去理解这个?
3:这个更不懂
for page in range(1, pages+1):
url = "https://search.bilibili.com/all?keyword={}&order={}&duration=4&tids_1=36&page={}".format(keyword, order[i], page)
text = get_html(url)
datas = get_datas(text)
# 为每种排序创建一个文本文件单独存放
with open(order_name[i]+'.txt', 'a', encoding="utf-8") as file:
for video_title, video_URL, video_watch, video_dm, video_time, video_up in grouped(datas, 6):
file.write(' + '.join([str(index), video_title, video_URL, video_watch, video_dm, video_time, video_up, '\n']))
index += 1
# 做一只善意的爬虫,不要给服务器带来负担
time.sleep(1)
求指导啊
|
|