Helius
2021-05-25 2d398a2bbd4a210ffd885f0b0b0a0f99edd84707
src/test/java/com/xcong/excoin/XchTest.java
@@ -5,6 +5,7 @@
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xcong.excoin.modules.coin.parameter.dto.CoinInListDto;
import com.xcong.excoin.modules.coin.service.CoinService;
@@ -15,7 +16,12 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.ClassUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@@ -60,7 +66,7 @@
    @Test
    public void orderUsdtProfitTest() {
        xchProfitService.usdtProfitDistributorByOrderId(7L);
        xchProfitService.usdtProfitDistributorByOrderId(17L);
    }
//
//    @Autowired
@@ -97,4 +103,62 @@
        coin.setPageSize(10);
        coinService.coinInList(coin);
    }
    public static void main(String[] args) {
//        String s = execCurl("https://api2.chiaexplorer.com/blockchainSummary");
//        System.out.println(s);
        String body = HttpRequest.get("https://api2.chiaexplorer.com/blockchainSummary").execute().body();
        System.out.println(body);
    }
    private static String execCurl(String url) {
        String[] cmds = {"curl", url
                , "-H", "sec-ch-ua: \" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\""
                ,"-H", "Accept: application/json, text/plain, */*"
                ,"-H", "Referer: https://www.chiaexplorer.com/"
                ,"-H", "sec-ch-ua-mobile: ?0"
                ,"-H", "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"
                ," --compressed"};
        ProcessBuilder process = new ProcessBuilder(cmds);
        Process p;
        try {
            p = process.start();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            StringBuilder builder = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                builder.append(line);
                builder.append(System.getProperty("line.separator"));
            }
            return builder.toString();
        } catch (IOException e) {
            System.out.print("error");
            e.printStackTrace();
        }
        return null;
    }
    @Test
    public void pyExec() {
        String result = "";
        String path = ClassUtils.getDefaultClassLoader().getResource("").getPath();
        String filePath = path + "static/xch.py";
        System.out.println(filePath);
        try {
            Process process = Runtime.getRuntime().exec("python " + filePath);
            process.waitFor();
            InputStreamReader ir = new InputStreamReader(process.getInputStream());
            LineNumberReader input = new LineNumberReader(ir);
            result = input.readLine();
            input.close();
            ir.close();
//            process.waitFor();
        } catch (IOException | InterruptedException e) {
            System.out.println(11);
        }
        System.out.println(result);
    }
}