自动化刷题小练习

驾校题库自动化刷题,使用了selenium以及requests等一些爬虫用的库

python 复制代码
from selenium import webdriver
from selenium.webdriver.common.by import By
import requests
import re
import time
driver=webdriver.Chrome()

driver.get("https://www.jsyks.com/kms-mnks")

question_list=driver.find_elements(By.CSS_SELECTOR,"div.Exam ul li")
print(question_list)

for li in question_list:
    answer_id=li.get_attribute("c")
    # print(answer_id)
    link=f'https://tiba.jsyks.com/Post/{answer_id}.htm'
    """
    通过 request获取数据
    """
    response=requests.get(link)
    html_data=response.text
    # print(html_data)
    a=re.findall('<br/>答案:<u>(.*?)</u>',html_data)[0]
#     获取答案内容
    bs=li.find_elements(By.CSS_SELECTOR,"b")
    for b in bs:
        choose=b.text
        if choose=="正确":
            choose="对"
        elif choose=="错误":
            choose="错"
        if len(choose)>2:
            choose=choose[0]
        for ans in a:
            if choose == ans:
                b.click()


submit=driver.find_element(By.CSS_SELECTOR,"div.ExamBtn u.btnJJ")
submit.click()
time.sleep(30)
相关推荐
Blossom.1187 分钟前
Prompt工程与思维链优化实战:从零构建动态Few-Shot与CoT推理引擎
人工智能·分布式·python·智能手机·django·prompt·边缘计算
haimin03711 小时前
linux设置CPU固定频率
linux·运维·服务器
一条咸鱼¥¥¥1 小时前
【运维经验】服务器磁盘做镜像的方法
运维·服务器·windows·经验分享
渣渣盟1 小时前
NFS服务器配置全攻略:从入门到精通
linux·运维·服务器
一只旭宝1 小时前
Linux专题九:I/O复用(水平以及边缘触发放到libevent库那一专题细讲)
linux·运维·服务器
love530love2 小时前
Windows 11 下 Z-Image-Turbo 完整部署与 Flash Attention 2.8.3 本地编译复盘
人工智能·windows·python·aigc·flash-attn·z-image·cuda加速
I · T · LUCKYBOOM2 小时前
iptables防火墙
linux·运维·服务器·网络·安全
MediaTea2 小时前
Python:模块 __dict__ 详解
开发语言·前端·数据库·python
jarreyer2 小时前
python,numpy,pandas和matplotlib版本对应关系
python·numpy·pandas
凌波粒3 小时前
Linux-Ubuntu系统环境搭建
linux·运维·ubuntu