jdck获取

星扬
2023-07-04 / 0 评论 / 154 阅读 / 正在检测是否收录...
import java.util.Scanner;

public class jdck {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("请输入Cookie字符串:");
        String cookie = scanner.nextLine();

        String ptKey = extractValueFromCookie(cookie, "pt_key");
        String ptPin = extractValueFromCookie(cookie, "pt_pin");

        System.out.println("pt_key=" + ptKey+";"+"pt_pin="+ptPin+";");
    }

    private static String extractValueFromCookie(String cookie, String key) {
        String value = null;

        String keyWithEqualSign = key + "=";
        int startIndex = cookie.indexOf(keyWithEqualSign);
        if (startIndex != -1) {
            startIndex += keyWithEqualSign.length();
            int endIndex = cookie.indexOf(";", startIndex);
            if (endIndex == -1) {
                endIndex = cookie.length();
            }
            value = cookie.substring(startIndex, endIndex).trim();
        }

        return value;
    }
}
2

评论 (0)

取消