• 脚本-抽取配置文件


    要获取不同版本的下载链接需要通过三次点击才能进入到有下载链接的Html页,想写爬虫的话需要使用selenium去实现点击功能,然后这个网站比较乱,所以根据Xpath也不太好写(可能得写好多异常处理),所以我选择手动获取下载链接。
    姐,我现在手动收集了187个链接,这些包括了所有的大类。我先把这些文件的config收集好发给你。
    这个图就是代表三个大类。每个类里面也包含了很多不同版本的ROM压缩包。
    在这里插入图片描述

    要获取不同版本的下载链接需要通过三次点击才能进入到有下载链接的Html页,想写爬虫的话需要使用selenium去实现点击功能,然后这个网站比较乱,所以根据Xpath也不太好写(可能得写好多异常处理),所以我选择手动获取下载链接。
    在这里插入图片描述

    学习
    echo "定义一个字符串变量"
     
    str="hello"
     
    echo "等值比较"
     
    if [ "${str}" = "hello" ]; then
        echo "字符串相等"
    else
        echo "字符串不相等"
    fi
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    关键字if与括弧之间、括弧与双引号之间、双引号和等号之间必须加空格;这个非常重要,当初排查问题的时候参考了一个站内大佬的笔记

    Linux服务器间的数据交互

    现在有两个IP不同的服务器节点,可以用scp命令交互。
    在这里插入图片描述

    对比仅UI不同的线刷包

    在这里插入图片描述
    在这里插入图片描述

    脚本整理

    download

    # !/bin/sh
    cat ~/project/xiaomi/link.txt | while read line
    do
        echo "$line"
        wget -P ~/project/xiaomi/download/ ${line}
    done
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    tar or unzip

    # !/bin/sh
    for file in $(ls ~/project/download/)
    do
        # echo $file
        filename=${file}
        tarname=${filename:0-3}
        targzname=${filename:0-6}
        zipname=${filename:0-3}
        if [ "${tarname}" = "tgz" ]; then
            tar -zxvf ~/project/download/${file} -C ~/project/unzip/ 
    
        elif [ "${targzname}" = "tar.gz" ]; then
            tar -zxvf ~/project/download/${file} -C ~/project/unzip/
    
        elif [ "${zipname}" = "zip" ]; then
            unzip -d ~/project/unzip/${file} ~/project/download/${file}
        fi
        rm -r ~/project/download/${file}
    done
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    extract boot.img

    # !/bin/sh
    boot_path='~/project/xiaomi/boot'
    
    for file2 in $(ls ~/project/xiaomi/unzip/)
    do
        cd ~/project/xiaomi/unzip/"${file2}"
        for boot in $(find ./ -name boot.img)
        do
            mkdir ~/project/xiaomi/boot/${file2}
            cp ${boot} ~/project/xiaomi/boot/${file2}/
        done
    done
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    extract-ikconfig

    # !/bin/sh
    for file in $(ls ~/project/boot)
    do
        ~/tool/imjtool.ELF64 ~/project/boot/${file}/boot.img extract
        if [ -e ./extracted/kernelimage.gz ]; then
            mv ./extracted/kernelimage.gz ./extracted/kernelimage
        fi
        ~/tool/extract-ikconfig ~/project/extracted/kernelimage > ~/project/config_file/${file}.txt
        rm -rf ~/project/extracted
    done
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    rename txt to config

    import os, sys
    
    
    path = os.path.dirname(os.path.abspath(__file__))
    def rename(path, num=0):
        # 对目录下的文件进行遍历
        num = 0
        for file in os.listdir(path):
            num = num+1
            # print(file)
            newName = file.replace(".txt", ".config")
    
            os.rename(os.path.join(path, file), os.path.join(path, newName))
        print(num)
    rename(str(path)+'/config_file')
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    文件名的含义

    plato_ru_global_images_V13.0.4.0.SLQRUXM_20220920.0000.00_12.0_global.txt
    1.plato是手机型号的代号,小米12T
    2.若_global_images代表全球版,若前面有字符
    ru 代表俄罗斯版
    tw代表台湾版本
    若只出现images则代表国行版
    3.V13.0.3.0.SLQTWXM代表MIUI版本
    4.20221008.0000.00代表出版时间
    5.12.0代表Android版本

  • 相关阅读:
    【linux下vscode头文件出现无法跳转的问题解决方案】【includepath波浪线】
    前后端加密解密工具类(前端rsa加密,后端进行解密)
    Synchronized锁详解
    Python清理数据的常用方法总结
    机器学习算法(二十四):启发式算法优化机器学习算法
    【数据结构】查找算法和堆栈的应用
    RabbitMQ与Erlang版本对应关系
    【C++】C++11——lambda表达式
    Mybatis-Plus中的and和or用法
    jmeter发送请求参数如何使用变量
  • 原文地址:https://blog.csdn.net/weixin_43898134/article/details/127897560