刷播放量爬虫

刷播放量爬虫

今天去同学github踩踩,看到个刷播放的爬虫,好用!怎么没早点看见hh

链接:yangyaojia/EducoderWatchedAll: YJSchaf来了全看了 (github.com)

一开始不知道他搁哪找的链接,原来在视频资源的网络界面很明显就看到json了,我怎么就没想到里面会有呢!

然后点开一个视频看一会,发现告知观看进度的api是怎么调用的,OK了。

收获
一直想写个educoder的爬虫,太懒没写。。(爬大家交上的图片,从而获取作业答案),自己写估计也想不到看网络,然后陷入瞎猜参数、url ➡ 猜不中跪了

平时很少仔细看网络,我太懒了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import requests

# MAX_LEN: 修改观看时间
MAX_LEN = 3600
print("YJSchaf替你把视频全看了")

courseId = "。。" #input("输入课程ID:")
# 身份认证的两个cookie,我一上来是在浏览器设置看的
c1 = "。。" #input("autologin_trustie:")
c2 = "。。" #input("_educoder_session:")

headers = {
'Host': 'data.educoder.net',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0',
"Accept": "application/json",
"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Accept-Encoding": "gzip, deflate",
"Referer": "https://www.educoder.net/classrooms/" + courseId + "/video",
"Content-Type": "application/json; charset=utf-8",
"Origin": "https://www.educoder.net",
"Connection": "keep-alive",
"Cookie": "autologin_trustie="+c1+";"+"_educoder_session="+c2
}

vedios_info_url = "https://data.educoder.net/api/courses/" + courseId + "/course_videos.json?coursesId=" + courseId + "&id=" + courseId + "&limit=100"
vedios_info = requests.get(vedios_info_url, headers = headers).json()

post_url = "https://data.educoder.net/api/watch_video_histories.json"

for v in vedios_info["videos"]:

req_payload = {
"point":0,
"video_id": v["id"],
"course_id": courseId ,
"duration": MAX_LEN,
"device": "pc"
}

response = requests.post(post_url, json = req_payload, headers = headers).json()

update_payload = {
"point": MAX_LEN,
"log_id": response["log_id"],
"watch_duration": MAX_LEN,
"total_duration": MAX_LEN,
"ed":"1"
}

response = requests.post(post_url, json = update_payload, headers = headers).json()

if(response["message"] == "success"):
print("【success】" + v["title"])
else:
print("【fail】" + v["title"])

评论