Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,19 @@ proxyMode=ROUND_ROBIN
2. 执行jar时加入`-Dfile.encoding=utf-8`,即`java -Dfile.encoding=utf-8 -jar 91160-cli.jar init|register`;
3. 终端不要用`powershell`,要用`cmd.exe`;

## Development 开发者

### 如何编译

```bash
./build.sh
```
随后运行
```
java -jar target/91160-cli-jar-with-dependencies.jar register -c config.properties
```


## 赞赏作者

如果您觉得`91160-cli`对你有帮助,可以请作者喝杯咖啡哦~
Expand Down
56 changes: 56 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

# Simple Build Script for 91160-cli
# This script provides a simpler way to build the application without complex assembly

set -e # Exit on any error

echo "=== 91160-cli Simple Build Script ==="
echo "Current directory: $(pwd)"

# Check if we're in the right directory
if [ ! -f "pom.xml" ]; then
echo "Error: pom.xml not found. Please run this script from the project root directory."
exit 1
fi

# Check Java version
echo "Checking Java version..."
java -version

# Check if Maven is available
if ! command -v mvn &> /dev/null; then
echo "Maven not found. Installing Maven..."

# Try to install Maven using package manager
if command -v apt-get &> /dev/null; then
echo "Installing Maven via apt-get..."
sudo apt-get update && sudo apt-get install -y maven
elif command -v yum &> /dev/null; then
echo "Installing Maven via yum..."
sudo yum install -y maven
elif command -v brew &> /dev/null; then
echo "Installing Maven via brew..."
brew install maven
else
echo "Error: Cannot install Maven automatically. Please install Maven manually."
echo "Download from: https://maven.apache.org/download.cgi"
exit 1
fi
fi

echo "Maven version:"
mvn --version

# Clean previous builds
echo "Cleaning previous builds..."
mvn clean

# Compile and package (this will create the jar-with-dependencies)
echo "Compiling and packaging..."
mvn package

# Check if build was successful
if [ -f "target/91160-cli-jar-with-dependencies.jar" ]; then
echo "✅ Build successful!"
echo "JAR file created: target/91160-cli-jar-with-dependencies.jar"
46 changes: 35 additions & 11 deletions src/main/java/com/github/pengpan/client/MainClient.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
package com.github.pengpan.client;

import java.util.List;
import java.util.Map;

import com.github.pengpan.common.proxy.Proxy;
import com.github.pengpan.common.retry.Retry;
import com.github.pengpan.entity.BrushSch;
import com.github.pengpan.entity.CheckUser;
import com.github.pengpan.entity.CheckUserV3;
import com.github.pengpan.entity.DoctorSch;

import okhttp3.ResponseBody;
import retrofit2.Response;
import retrofit2.http.*;

import java.util.List;
import java.util.Map;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Url;

/**
* @author pengpan
Expand All @@ -24,6 +34,10 @@ public interface MainClient {
@POST
CheckUser checkUser(@Url String url, @FieldMap Map<String, String> fields);

@FormUrlEncoded
@POST
CheckUserV3 checkUserV3(@Url String url, @FieldMap Map<String, String> fields);

@FormUrlEncoded
@POST
Response<Void> doLogin(@Url String url, @FieldMap Map<String, String> fields);
Expand Down Expand Up @@ -73,19 +87,29 @@ String orderPage(@Path("unitId") String unitId,
@FormUrlEncoded
@POST("/guahao/ysubmit.html")
Response<Void> doSubmit(@Field("sch_data") String schData,
@Field("unit_id") String unitId,
@Field("dep_id") String depId,
@Field("doctor_id") String doctorId,
@Field("schedule_id") String schId,
@Field("mid") String memberId,
@Field("addressId") String addressId,
@Field("address") String address,
@Field("disease_input") String diseaseInput,
@Field("order_no") String orderNo,
@Field("disease_content") String diseaseContent,
@Field("accept") String accept,
@Field("unit_id") String unitId,
@Field("schedule_id") String schId,
@Field("dep_id") String depId,
@Field("his_dep_id") String hisDepId,
@Field("sch_date") String schDate,
@Field("time_type") String time_type,
@Field("doctor_id") String doctorId,
@Field("his_doc_id") String hisDocId,
@Field("detlid") String detlid,
@Field("detlid_realtime") String detlid_realtime,
@Field("level_code") String level_code,
@Field("addressId") String addressId,
@Field("address") String address,
@Field("hisMemId") String hisMemId);
@Field("is_hot") String isHot,
@Field("pay_online") String payOnline,
@Field("detl_name") String detlName,
@Field("to_date") String toDate,
@Field("his_mem_id") String hisMemId);

@GET("/favicon.ico")
Response<Void> serverTime();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/pengpan/cmd/Register.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private void checkBasicConfig(Config config) {
Assert.notEmpty(config.getDoctorId(), "[doctorId]不能为空,请检查配置文件");
Assert.notEmpty(config.getWeeks(), "[weeks]不能为空,请检查配置文件");
Assert.notEmpty(config.getDays(), "[days]不能为空,请检查配置文件");
Assert.isTrue(config.getSleepTime() >= 0, "[sleepTime]格式不正确,请检查配置文件");
Assert.isTrue(config.getRandomSleepTime() >= 0, "[sleepTime]格式不正确,请检查配置文件, 例如 \"sleepTime=1000-2000 或者\" sleepTime=1000\" ");
if (StrUtil.isNotBlank(config.getBrushStartDate())) {
Date brushStartDate = CommonUtil.parseDate(config.getBrushStartDate(), DatePattern.NORM_DATE_PATTERN);
Assert.notNull(brushStartDate, "[brushStartDate]格式不正确,请检查配置文件");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class SystemConstant {

public final static String PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDWuY4Gff8FO3BAKetyvNgGrdZM9CMNoe45SzHMXxAPWw6E2idaEjqe5uJFjVx55JW+5LUSGO1H5MdTcgGEfh62ink/cNjRGJpR25iVDImJlLi2izNs9zrQukncnpj6NGjZu/2z7XXfJb4XBwlrmR823hpCumSD1WiMl1FMfbVorQIDAQAB";

public final static String DEFECT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36";
public final static String DEFECT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36";

public final static String DOMAIN = "https://www.91160.com";

Expand All @@ -22,6 +22,8 @@ public class SystemConstant {
public final static String LOGIN_URL = "https://user.91160.com/login.html";

public final static String CHECK_USER_URL = "https://user.91160.com/checkUser.html";

public final static String CHECK_USER_V3_URL = "https://www.91160.com/user/check.html";

public final static String CAPTCHA_URL = "https://user.91160.com/Captcha.png";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package com.github.pengpan.common.cookie;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Cookie;

/**
* 默认Cookie配置
* 包含固定的Cookie值和动态生成的值
*
* @author wufei
*/
@Slf4j
public class DefaultCookieConfig {
//TODO 应该从用户配置中获取
// 固定的Cookie值(从header.yaml中提取)
private static final String FIXED_COOKIES = "";

/**
* 生成动态Cookie值
*/
public static class DynamicCookies {

/**
* 生成DKLFFDKD Cookie(加密令牌)
*/
public static String generateDKLFFDKD() {
String key = RandomUtil.randomString(32);
String val = RandomUtil.randomString(32);
long tm = System.currentTimeMillis() / 1000;

String json = String.format("{\"key\":\"%s\",\"val\":\"%s\",\"tm\":%d}", key, val, tm);
return java.net.URLEncoder.encode(json, java.nio.charset.StandardCharsets.UTF_8);
}

/**
* 生成FISKCDDCC Cookie(另一个加密令牌)
*/
public static String generateFISKCDDCC() {
return RandomUtil.randomString(32);
}

/**
* 生成__guid Cookie(全局唯一标识符)
*/
public static String generateGuid() {
return RandomUtil.randomString(24) + "." + RandomUtil.randomInt(10000000, 99999999);
}

/**
* 生成__jsluid_s Cookie(JavaScript库唯一ID)
*/
public static String generateJsluidS() {
return RandomUtil.randomString(32);
}

/**
* 生成access_hash Cookie(访问哈希值)
*/
public static String generateAccessHash() {
String hash = RandomUtil.randomString(32);
String suffix = RandomUtil.randomString(12) + System.currentTimeMillis();
return hash + suffix;
}

/**
* 生成PHPSESSID Cookie(PHP会话ID)
*/
public static String generatePhpSessionId() {
return RandomUtil.randomString(26);
}
}

/**
* 获取默认Cookie字符串
* 包含固定Cookie和动态生成的Cookie
*/
public static String getDefaultCookieString() {
StringBuilder cookieBuilder = new StringBuilder();

// 添加动态生成的Cookie
cookieBuilder.append("DKLFFDKD=").append(DynamicCookies.generateDKLFFDKD()).append("; ");
cookieBuilder.append("PHPSESSID=").append(DynamicCookies.generatePhpSessionId()).append("; ");
cookieBuilder.append("__jsluid_s=").append(DynamicCookies.generateJsluidS()).append("; ");
cookieBuilder.append("autoLoginInfo=0e9fe9374589fdb45bf40ad5f50e5e8f; ");
cookieBuilder.append("__guid=").append(DynamicCookies.generateGuid()).append("; ");
cookieBuilder.append("access_hash=").append(DynamicCookies.generateAccessHash()).append("; ");
cookieBuilder.append("ip_city=sz; ");
cookieBuilder.append("FISKCDDCC=").append(DynamicCookies.generateFISKCDDCC()).append("; ");

// 添加固定的Cookie
cookieBuilder.append(FIXED_COOKIES);

return cookieBuilder.toString();
}

/**
* 将Cookie字符串转换为Cookie对象列表
*/
public static List<Cookie> parseCookieString(String cookieString, String domain) {
List<Cookie> cookies = new ArrayList<>();

if (StrUtil.isBlank(cookieString)) {
return cookies;
}

String[] cookiePairs = cookieString.split(";");
for (String pair : cookiePairs) {
pair = pair.trim();
if (StrUtil.isBlank(pair)) {
continue;
}

String[] keyValue = pair.split("=", 2);
if (keyValue.length == 2) {
String name = keyValue[0].trim();
String value = keyValue[1].trim();

// 创建Cookie对象,设置较长的过期时间
Cookie cookie = new Cookie.Builder()
.name(name)
.value(value)
.domain(domain)
.path("/")
.expiresAt(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(30))
.build();

cookies.add(cookie);
}
}

return cookies;
}

/**
* 获取www.91160.com的默认Cookie
*/
public static List<Cookie> getDefaultWwwCookies() {
String cookieString = getDefaultCookieString();
return parseCookieString(cookieString, "www.91160.com");
}

/**
* 获取user.91160.com的默认Cookie
*/
public static List<Cookie> getDefaultUserCookies() {
String cookieString = getDefaultCookieString();
return parseCookieString(cookieString, "user.91160.com");
}
}
Loading