zoukankan      html  css  js  c++  java
  • 常州大学/企业微信/电费查询脚本

    企业微信 电费查询脚本

    博客 https://blog.nanshaobit.top/106

    仓库

    account 为用户id, 可抓包获得(随机也可,存在就行)。
    aid 应用id 两个校区不同

    获取楼栋接口

    • url: http://wxxy.cczu.edu.cn/wechat/callinterface/queryElecBuilding.html
    • method: POST
    • data: 具体见 main.py:get_area()
    {
        "aid": area["aid"], // 应用ID
        "account": "100000", // 用户id
        "area": area["value"] // 区域
    }
    
    • 数据位置: 返回数据 json["buildingtab"]

    查询电费接口

    • url: http://wxxy.cczu.edu.cn/wechat/callinterface/queryElecRoomInfo.html
    • method: POST
    • data: 具体见 main.py:get_data()
    // 除有注释外,其他内容正常情况不需要修改。
    {
        "aid": area["aid"], // 应用ID
        "account": "100000", // 用户id
        "area": area["value"] // 区域
        
        "building": str(building), // 楼栋信息
        "floor": '{"floorid":"","floor":""}', // 置空
        "room": f'{{"room":"","roomid":"{rid}"}}'} // 房间id
    }
    
    • 数据位置: 返回数据 json["errmsg"] (可能出错, 提示也在该位置,需要判断)

    脚本

    依赖库: requests

    [脚本]main.py 使用控制台输入方式交互, 可修改为其他方式交互 如:web、机器人

    # @DateTime     : 2021-10-20 12:57
    # @Author       : Nanshao
    # @Mail         : Nanshao@n-s.fun
    # @Description  :
    
    import requests
    
    """
    所有输入 均未做容错处理。
    """
    
    s = requests.Session()
    
    
    def get_input_from_ls(ls, k):
        for i, v in enumerate(ls):
            print(f"{i}: -> {v[k]}")
    
        return ls[int(input("输入序号即可:"))]
    
    
    def get_area():
        ls_area = [{
            "title": "西太湖校区(1-9号楼)",
            "value": '{"area":"西太湖校区","areaname":"西太湖校区"}',
            "aid": "0030000000002501"
        }, {
            "title": "武进校区及西太湖校区(10-11号楼)",
            "value": '{"area":"武进校区","areaname":"武进校区"}',
            "aid": "0030000000002502"
        }]
        return get_input_from_ls(ls_area, "title")
    
    
    def get_building(area):
        with s.post("http://wxxy.cczu.edu.cn/wechat/callinterface/queryElecBuilding.html", data={
            "aid": area["aid"],
            "account": "100000",
            "area": area["value"],
        }) as resp:
            ls_building = resp.json().get("buildingtab")
            return get_input_from_ls(ls_building, "building")
    
    
    def get_data(area, building, rid):
        print("query")
        print("*" * 50)
        url = "http://wxxy.cczu.edu.cn/wechat/callinterface/queryElecRoomInfo.html"
        with s.post(url, data={
            "aid": area["aid"],
            "account": "100000",
            "area": area["value"],
            "building": str(building),
            "floor": '{"floorid":"","floor":""}',
            "room": f'{{"room":"","roomid":"{rid}"}}'}) as resp:
            print(resp.json())
            print(resp.json()["errmsg"])
    
    
    def query():
        area = get_area()
        building = get_building(area)
        rid = input("输入房间号:")
        get_data(area, building, rid)
    
    
    if __name__ == '__main__':
        query()
    

    个人博客: https://blog.nanshaobit.top
    CSDN: https://blog.csdn.net/LZ_nanshao
    码云: https://gitee.com/nanshaobit
    Github: https://github.com/nanshaobit

  • 相关阅读:
    按键消抖电路设计——你们遇到的都是伪消抖
    FPGA工程中用C语言对文件进行处理_生成mif文件
    verilog中always块延时总结
    FPGA中改善时序性能的方法_advanced FPGA design
    verilog中连续性赋值中的延时
    verilog中读取文件中的字符串_modelsim高级仿真
    FPGA知识大梳理(四)FPGA中的复位系统大汇总
    c++虚函数几种实现方法
    c++逐渐退化的虚函数
    c++管理内存的几种方式
  • 原文地址:https://www.cnblogs.com/nanshaobit/p/cczu_wechat_query_elec_room_info.html
Copyright © 2011-2022 走看看