From 7f2f5ef5637a6871f4329e464eeba97eb59e94a3 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期三, 21 八月 2019 10:45:38 +0800 Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div --- fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java index e4fc9c2..55807c4 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java @@ -13,6 +13,7 @@ import javax.script.Invocable; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; +import javax.script.ScriptException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.PostMethod; @@ -496,14 +497,23 @@ } static String jdGoodsJs = null; - - public static String getPDDGoodsId(String url) { + static ScriptEngine engine = null; + static { if (jdGoodsJs == null) jdGoodsJs = getJDGoodsJS(); ScriptEngineManager manager = new ScriptEngineManager(); - ScriptEngine engine = manager.getEngineByName("javascript"); + engine = manager.getEngineByName("javascript"); try { engine.eval(jdGoodsJs); + } catch (ScriptException e) { + e.printStackTrace(); + } + + } + + public static String getPDDGoodsId(String url) { + + try { if (engine instanceof Invocable) { Invocable in = (Invocable) engine; String goodsId = in.invokeFunction("getGoodsId", url).toString(); -- Gitblit v1.8.0