First Commit
This commit is contained in:
44
src/test/java/BaseResponseTest.java
Normal file
44
src/test/java/BaseResponseTest.java
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import com.google.protobuf.nano.MessageNano;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import static nano.BaseResponse.Base_Response;
|
||||
|
||||
@Slf4j
|
||||
public class BaseResponseTest {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <U extends MessageNano> void main(String args[]) {
|
||||
String path = "C:\\Users\\Administrator\\Desktop\\Emoney\\2422-different-span\\300684-2422-monthly-resp";
|
||||
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(new File(path));
|
||||
byte[] data=new byte[in.available()];
|
||||
in.read(data);
|
||||
in.close();
|
||||
|
||||
Base_Response baseResponse = Base_Response.parseFrom(data);
|
||||
|
||||
String className = baseResponse.detail.getTypeUrl().replace("type.googleapis.com/", "");
|
||||
className = "nano." + className.replace("_", "") + "$" + className;
|
||||
|
||||
Class<U> clazz = (Class<U>)Class.forName(className);
|
||||
|
||||
U nanoResponse = (U) MessageNano.mergeFrom((MessageNano)clazz.getDeclaredConstructor().newInstance(), baseResponse.detail.getValue());
|
||||
|
||||
ObjectNode jo = new ObjectMapper().valueToTree(nanoResponse);
|
||||
log.info(jo.toPrettyString());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
37
src/test/java/ByteBuddyTest.java
Normal file
37
src/test/java/ByteBuddyTest.java
Normal file
@@ -0,0 +1,37 @@
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import quant.rich.emoney.patch.okhttp.PatchOkHttp;
|
||||
import quant.rich.emoney.patch.okhttp.PatchOkHttpRule;
|
||||
import quant.rich.emoney.util.EncryptUtils;
|
||||
|
||||
public class ByteBuddyTest {
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
|
||||
PatchOkHttp.apply(
|
||||
r -> r.not(a -> a.isHttps())
|
||||
.overrideIf("User-Agent", "okhttp/3.12.2")
|
||||
);
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
Request.Builder requestBuilder = new Request.Builder()
|
||||
.url("http://localhost")
|
||||
.get();
|
||||
|
||||
Request request = requestBuilder.build();
|
||||
request.newBuilder();
|
||||
final Call call = client.newCall(request);
|
||||
Response response = call.execute();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
68
src/test/java/EmoneyScraper.java
Normal file
68
src/test/java/EmoneyScraper.java
Normal file
@@ -0,0 +1,68 @@
|
||||
import com.microsoft.playwright.*;
|
||||
import com.microsoft.playwright.BrowserType.LaunchOptions;
|
||||
import com.microsoft.playwright.Route.ResumeOptions;
|
||||
import com.microsoft.playwright.options.HttpHeader;
|
||||
import com.microsoft.playwright.options.Proxy;
|
||||
import com.microsoft.playwright.options.WaitUntilState;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class EmoneyScraper {
|
||||
public static void main(String[] args) {
|
||||
try (Playwright playwright = Playwright.create()) {
|
||||
// 设置浏览器上下文选项,包括 User-Agent
|
||||
Proxy proxy = new Proxy("http://127.0.0.1:8888");
|
||||
LaunchOptions launchOptions = new BrowserType.LaunchOptions()
|
||||
.setHeadless(true)
|
||||
.setProxy(proxy);
|
||||
Browser browser = playwright.chromium().launch(launchOptions);
|
||||
BrowserContext context = browser.newContext(new Browser.NewContextOptions()
|
||||
.setUserAgent("Mozilla/5.0 (Linux; Android 9; PCRT00 Build/PQ3B.190801.11191547; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.114 Mobile Safari/537.36"));
|
||||
|
||||
// 设置全局请求头
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Upgrade-Insecure-Requests", "1");
|
||||
headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
|
||||
headers.put("X-Requested-With", "cn.emoney.emstock");
|
||||
headers.put("Sec-Fetch-Site", "none");
|
||||
headers.put("Sec-Fetch-Mode", "navigate");
|
||||
headers.put("Sec-Fetch-User", "?1");
|
||||
headers.put("Sec-Fetch-Dest", "document");
|
||||
headers.put("Accept-Encoding", "gzip, deflate");
|
||||
headers.put("Accept-Language", "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7");
|
||||
|
||||
context.setExtraHTTPHeaders(headers);
|
||||
context.route("**/*", route -> {
|
||||
Request request = route.request();
|
||||
List<HttpHeader> requestHeaderList = request.headersArray();
|
||||
Map<String, String> requestHeaders = new HashMap<>();
|
||||
for (HttpHeader header : requestHeaderList) {
|
||||
requestHeaders.put(header.name, header.value);
|
||||
}
|
||||
requestHeaders.remove("sec-ch-ua");
|
||||
requestHeaders.remove("sec-ch-ua-mobile");
|
||||
requestHeaders.remove("sec-ch-ua-platform");
|
||||
route.resume(new ResumeOptions().setHeaders(requestHeaders));
|
||||
});
|
||||
|
||||
Page page = context.newPage();
|
||||
|
||||
page.onResponse(handler -> {
|
||||
String url = handler.request().url();
|
||||
if (url.endsWith(".js")) {
|
||||
String str = handler.request().response().text();
|
||||
System.out.println(str);
|
||||
}
|
||||
});
|
||||
|
||||
String url = "https://appstatic.emoney.cn/html/emapp/stock/note/?name=10003001&emoneyScaleType=0&emoneyLandMode=0&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6IkpXVCJ9.eyJ1dWQiOjEwMTA2NjAwNDcsInVpZCI6MjQ3NjY5MDIsImRpZCI6IjdmOTA3N2VjZTlmMWIxMjQ4NmZmYjRmNDhjMzdkODJhIiwidHlwIjoxLCJhY2MiOiJlbXkxNzMwOTc4Iiwic3d0IjoxLCJsZ3QiOjE3NDQ1OTY2NTY3MTgsIm5iZiI6MTc0NDU5NjY1NiwiZXhwIjoxNzQ2MzI0NjU2LCJpYXQiOjE3NDQ1OTY2NTZ9.SHLqiavrzkwtLfxaWbA6GfnF7iBqbjnv86PTOhumiGc";
|
||||
|
||||
page.navigate(url, new Page.NavigateOptions().setWaitUntil(WaitUntilState.NETWORKIDLE));
|
||||
|
||||
String html = page.content();
|
||||
System.out.println(html);
|
||||
|
||||
browser.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
48
src/test/java/FingerprintsSpliter.java
Normal file
48
src/test/java/FingerprintsSpliter.java
Normal file
@@ -0,0 +1,48 @@
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import quant.rich.emoney.entity.config.EmoneyRequestConfig;
|
||||
import quant.rich.emoney.entity.config.DeviceInfoConfig.DeviceInfo;
|
||||
|
||||
public class FingerprintsSpliter {
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
Pattern p = Pattern.compile("^(?<brand>.*?)/(?<product>.*?)/(?<device>.*?):(?<versionRelease>.*?)/(?<buildId>.*?)/(?<buildNumber>.*?):(?<buildType>.*?)/(?<buildTags>.*?)$");
|
||||
|
||||
List<String> lines = Files.readAllLines(Path.of("C:\\Users\\Administrator\\Downloads\\MagiskHidePropsConf-v6.1.2\\common\\prints.sh"));
|
||||
int count = 0;
|
||||
for(String line :lines) {
|
||||
if (!line.contains(":") || line.startsWith("#")) continue;
|
||||
String[] split = line.split(":", 3);
|
||||
String info = split[0];
|
||||
String manufacturer = split[1];
|
||||
String[] modelAndFingers = split[2].split("=");
|
||||
String model = modelAndFingers[0];
|
||||
String[] fingerprints = modelAndFingers[1].split(";");
|
||||
for(String fingerprint : fingerprints) {
|
||||
String realFinger = fingerprint.split("__")[0];
|
||||
// [brand]/[product]/[device]:[version.release]/[build.id]/[build.number]:[build.type]/[build.tags]
|
||||
|
||||
/*
|
||||
System.out.printf("Manufacturer: %s, deviceName: %s, fingerprint: %s\r\n",
|
||||
manufacturer,
|
||||
deviceName,
|
||||
realFinger);
|
||||
*/
|
||||
DeviceInfo deviceInfo = DeviceInfo.from(model, realFinger);
|
||||
// System.out.printf("deviceInfos.add(DeviceInfo.from(\"%s\", \"%s\", \"%s\"));\r\n", manufacturer, model, realFinger);
|
||||
System.out.println(deviceInfo.toString());
|
||||
// System.out.println(EmoneyHeaderConfig.getSdkLevel(deviceInfo.getVersionRelease()));
|
||||
count++;
|
||||
}
|
||||
};
|
||||
System.out.printf("Total fingers: %d\r\n", count);
|
||||
}
|
||||
|
||||
}
|
||||
31
src/test/java/JacksonObjectNodeToStringOrderTest.java
Normal file
31
src/test/java/JacksonObjectNodeToStringOrderTest.java
Normal file
@@ -0,0 +1,31 @@
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Base64;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import quant.rich.emoney.util.VersionComparator;
|
||||
|
||||
public class JacksonObjectNodeToStringOrderTest {
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
ObjectNode obj = new ObjectMapper().createObjectNode();
|
||||
obj.put("fuck", "me");
|
||||
obj.put("ass", "hole");
|
||||
System.out.println(obj.toString());
|
||||
System.out.println(obj.toPrettyString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
69
src/test/java/WeibaPlayground.java
Normal file
69
src/test/java/WeibaPlayground.java
Normal file
@@ -0,0 +1,69 @@
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Base64;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
|
||||
import quant.rich.emoney.util.VersionComparator;
|
||||
|
||||
public class WeibaPlayground {
|
||||
|
||||
private static final short[] XCUtil_short = new short[]{2176, 1289, 2869, 2868, 2854, 2893, 2904, 2219, 2231, 2231, 2227, 2297, 2284, 2284, 2228, 2214, 2218, 2209, 2210, 2285, 2215, 2230, 2220, 2216, 2210, 2218, 2234, 2210, 2285, 2208, 2220, 2222, 2284, 2221, 2214, 2228, 2227, 2219, 2220, 2221, 2214, 2285, 2227, 2219, 2227, 2300, 2218, 2215, 2302, 1330, 1378, 1393, 1382, 1321, 1971, 2022, 2044, 2034, 2043, 1960};
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
System.out.println(
|
||||
((Object)"ۤۢۢ").hashCode()
|
||||
|
||||
);
|
||||
System.out.println(decodeShort(XCUtil_short, 1, 1, 1397));
|
||||
// (1745665457, MTc0NTY2NTQ1N3xkZjJkOThjYw==)
|
||||
// FM%5C%29GMR%2BGMJ*G%2CqdScCdHMacRp%3D%3D
|
||||
Path path = Path.of("E:\\eclipse-workspace\\emoney-auto\\conf\\system\\emoneyRequest.androidChromeVersions.json");
|
||||
String str = Files.readString(path);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ArrayNode node = (ArrayNode) mapper.readTree(str);
|
||||
|
||||
List<String> ver = mapper.convertValue(node, new TypeReference<List<String>>() {});
|
||||
ver.sort(VersionComparator.INSTANCE.reversed());
|
||||
Set<String> verSet = new LinkedHashSet<>(ver);
|
||||
ver = List.copyOf(verSet);
|
||||
|
||||
ArrayNode ja = mapper.valueToTree(verSet);
|
||||
Files.writeString(path, ja.toPrettyString());
|
||||
//System.out.println(ccc("1745665457", "MTc0NTY2NTQ1N3xkZjJkOThjYw=="));
|
||||
}
|
||||
|
||||
public static String decodeShort(short[] sArr, int i, int i2, int i3) {
|
||||
char[] cArr = new char[i2];
|
||||
for (int i4 = 0; i4 < i2; i4++) {
|
||||
cArr[i4] = (char) (sArr[i + i4] ^ i3);
|
||||
}
|
||||
return new String(cArr);
|
||||
}
|
||||
|
||||
public static String ccc(String var0, String var1) throws UnsupportedEncodingException {
|
||||
String decoded = new String(Base64.getDecoder().decode(var1)).trim();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
// 获取时间戳最后一位作为减法因子(如 1745660488 → 8)
|
||||
int offset = var0.charAt(9) - '0'; // var0 是时间戳
|
||||
|
||||
for (char ch : decoded.toCharArray()) {
|
||||
if (ch == '=') continue;
|
||||
sb.append((char)(ch - offset));
|
||||
}
|
||||
|
||||
return URLEncoder.encode(sb.toString(), "UTF-8");
|
||||
}
|
||||
|
||||
}
|
||||
56
src/test/java/quant/rich/EmoneyAutoApplicationTests.java
Normal file
56
src/test/java/quant/rich/EmoneyAutoApplicationTests.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package quant.rich;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import nano.CandleStickNewWithIndexExResponse.CandleStickNewWithIndexEx_Response;
|
||||
import nano.CandleStickRequest.CandleStick_Request;
|
||||
import nano.CandleStickWithIndexRequest.CandleStickWithIndex_Request;
|
||||
import nano.CandleStickWithIndexRequest.CandleStickWithIndex_Request.IndexInfo;
|
||||
import quant.rich.emoney.EmoneyAutoApplication;
|
||||
import quant.rich.emoney.client.EmoneyClient;
|
||||
|
||||
|
||||
@SpringBootTest
|
||||
@ContextConfiguration(classes = EmoneyAutoApplication.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@Slf4j
|
||||
class EmoneyAutoApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
EmoneyClient.loginWithAnonymous();
|
||||
|
||||
CandleStickWithIndex_Request request = new CandleStickWithIndex_Request();
|
||||
|
||||
CandleStick_Request candleRequest = new CandleStick_Request();
|
||||
candleRequest.setBeginPosition(0)
|
||||
.setDataPeriod(50000)
|
||||
.setExFlag(0).setGoodsId(1300684)
|
||||
.setLastVolume(0).setLimitSize(250)
|
||||
.setReqFhsp(false).setReqHisShares(false);
|
||||
request.candleRequest = candleRequest;
|
||||
|
||||
//IndexInfo indexRequest = new IndexInfo().setIndexName("CPX");
|
||||
//request.indexRequest = new IndexInfo[] {indexRequest};
|
||||
|
||||
//emoneyClient.getEmoneyRequestHeader().setXProtocolId(2422).setXRequestIdWithTimestamp();
|
||||
|
||||
CandleStickNewWithIndexEx_Response response = EmoneyClient.post(
|
||||
request, CandleStickNewWithIndexEx_Response.class,
|
||||
2422, String.valueOf(System.currentTimeMillis()));
|
||||
//JSONObject jo = JSONObject.from(request);
|
||||
ObjectNode jo = new ObjectMapper().valueToTree(response);
|
||||
log.info(jo.toPrettyString());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
42
src/test/java/quant/rich/PatchOkHttpTest.java
Normal file
42
src/test/java/quant/rich/PatchOkHttpTest.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package quant.rich;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import quant.rich.emoney.patch.okhttp.RequestContext;
|
||||
import quant.rich.emoney.patch.okhttp.PatchOkHttpRule;
|
||||
|
||||
public class PatchOkHttpTest {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
|
||||
PatchOkHttpRule rule;
|
||||
RequestContext context;
|
||||
|
||||
rule = PatchOkHttpRule.when().isHttps().build();
|
||||
context = new RequestContext(Map.of(), "https", "localhost");
|
||||
|
||||
Assertions.assertTrue(rule.matches(context), "测试失败");
|
||||
|
||||
rule = PatchOkHttpRule.when().hostEndsWith("emoney.com")
|
||||
.or(r -> r.hostContains("emapp"))
|
||||
.build();
|
||||
context = new RequestContext(Map.of(), "https", "mbs.emoney.com");
|
||||
|
||||
Assertions.assertTrue(rule.matches(context), "测试失败");
|
||||
|
||||
context = new RequestContext(Map.of(), "https", "emapp-static.oss-cn-shanghai.aliyuncs.com");
|
||||
Assertions.assertTrue(rule.matches(context), "测试失败");
|
||||
|
||||
context = new RequestContext(Map.of(), "https", "hao123.com");
|
||||
Assertions.assertFalse(rule.matches(context), "测试失败");
|
||||
|
||||
|
||||
//Assertions.assertEquals("{\"info\":\"m\",\"weight\":\"100kg/m\"}", JSON.toJSONString(humanWeight));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user