这个是python脚本,还有插件版的,有空了会发出来,包括自动登录账号,刷视频课时和练习,知识竞赛,还有普法插件等。

使用步骤

考虑到使用有些复杂,准备出个视频版的教程和资源整合包,比较忙还没录视频,现在就先看着吧.....会用的自己就可以用了
1.安装python
2.安装python运行所需要的模块
3.移动selenium驱动文件到指定地点
4.要登录的账号进行配置

1.安装

python官网下载双击打开,记得勾选path

2.安装模块

用的有两个selenium,requests

3.下载对应浏览器的selenium驱动,放到浏览器目录下

你用的哪个浏览器就放到哪个浏览器下面去

4.要登录的账号进行配置

先去第二课堂把账号密码列表下载下来,是excel的
然后把账号密码放到python文件夹下的 账户.txt 文件夹里面

最后点击运行即可

全部代码如下

from selenium import webdriver
import time
import json
import requests
import random
requests.packages.urllib3.disable_warnings()

# 设置driver路径,这个是我的浏览器路径,要改成你的
location = r'D:\我的程序\360极速\360Chrome\Chrome\Application\360chrome.exe'

# selenium设置与启动
options = webdriver.ChromeOptions()
prefs = {"profile.managed_default_content_settings.images": 2}  # 无图模式访问,这样的话加载会快很多
options.add_experimental_option("prefs", prefs)
options.binary_location = location
driver=webdriver.Chrome(chrome_options=options)  
driver.get('https://www.2-class.com/competition')
# 这里是等待加载完成才这样设置的
time.sleep(5)

def login(account):
    #点击登录
    el = driver.find_element_by_xpath('//*[@id="app"]/div/div[1]/div/header/div/div[2]/div[2]/div/span/a')
    el.click()
    time.sleep(2)

    #account
    el = driver.find_element_by_xpath('//*[@id="account"]')
    el.send_keys(account)
    print(account)
    time.sleep(1)

    #password
    el = driver.find_element_by_xpath('//*[@id="password"]')
    el.send_keys('a1234567')

    #登录
    el = driver.find_element_by_css_selector("[type='submit']")
    el.click()
    time.sleep(2)

    #cookie和数据
    cookie = ''
    cookies=driver.get_cookies()
    for i in cookies:
        cookie = cookie + i['name'] + '=' + i['value'] + ';'
    reqtoken = driver.execute_script('return window.__DATA__.reqtoken')

    yi_jian_man_fen(cookie,reqtoken,account)

    #点击退出
    el = driver.find_element_by_xpath('//*[@id="app"]/div/div[1]/div/header/div/div[2]/div[2]/div/a')
    el.click()
    time.sleep(1)
    el = driver.find_element_by_xpath('//*[@id="app"]/div/div[1]/div/header/div/div[2]/div[2]/div/div/ul/li[6]/a')
    el.click()
    time.sleep(2)

#开始答题
def yi_jian_man_fen(cookie,reqtoken,account):
    url = 'https://www.2-class.com/api/quiz/commit'
    headers = {
        'Cookie': cookie,
        'Content-Type': 'application/json',
        'User-Agent': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50'
    }
    time = random.randint(100, 350)
    data = {
        "list": [
            {
                "questionId": 2986,
                "questionContent": "B"
            },
            {
                "questionId": 2989,
                "questionContent": "C"
            },
            {
                "questionId": 2990,
                "questionContent": "D"
            },
            {
                "questionId": 2959,
                "questionContent": "C"
            },
            {
                "questionId": 2928,
                "questionContent": "C"
            },
            {
                "questionId": 2960,
                "questionContent": "A"
            },
            {
                "questionId": 2961,
                "questionContent": "C"
            },
            {
                "questionId": 2897,
                "questionContent": "B"
            },
            {
                "questionId": 2930,
                "questionContent": "D"
            },
            {
                "questionId": 2898,
                "questionContent": "B"
            },
            {
                "questionId": 2963,
                "questionContent": "A"
            },
            {
                "questionId": 2932,
                "questionContent": "D"
            },
            {
                "questionId": 2901,
                "questionContent": "A"
            },
            {
                "questionId": 2966,
                "questionContent": "D"
            },
            {
                "questionId": 2934,
                "questionContent": "C"
            },
            {
                "questionId": 2904,
                "questionContent": "D"
            },
            {
                "questionId": 2907,
                "questionContent": "D"
            },
            {
                "questionId": 2972,
                "questionContent": "C"
            },
            {
                "questionId": 2973,
                "questionContent": "A"
            },
            {
                "questionId": 2912,
                "questionContent": "B"
            }
        ],
        "time": time,
        "reqtoken": reqtoken
    }

    result = requests.post(url=url, data=json.dumps(data), headers=headers, verify=False)
    print(account + '已经完成')

if __name__ == '__main__':
    accounts = []
    with open('账户.txt','r') as f:
        accounts = f.read().split('\n')

    try:
        for account in accounts:
            login(account)
    except:
        print('程序运行错误')

    driver.quit()   # 使用完, 记得关闭浏览器, 不然chromedriver.exe进程为一直在内存中.