|
|
@ -123,11 +123,10 @@ class AnalyzeRule(private var book: BaseBook? = null) { |
|
|
|
if (rule.rule.isNotEmpty()) { |
|
|
|
if (rule.rule.isNotEmpty()) { |
|
|
|
when (rule.mode) { |
|
|
|
when (rule.mode) { |
|
|
|
Mode.Js -> result = evalJS(rule.rule, result) |
|
|
|
Mode.Js -> result = evalJS(rule.rule, result) |
|
|
|
Mode.JSon -> result = |
|
|
|
Mode.JSon -> result = getAnalyzeByJSonPath(it).getStringList(rule.rule) |
|
|
|
getAnalyzeByJSonPath(it).getStringList(rule.rule) |
|
|
|
Mode.XPath -> result = getAnalyzeByXPath(it).getStringList(rule.rule) |
|
|
|
Mode.XPath -> result = |
|
|
|
Mode.Css -> result = getAnalyzeByJSoup(it).getStringList(rule.rule) |
|
|
|
getAnalyzeByXPath(it).getStringList(rule.rule) |
|
|
|
else -> result = rule.rule |
|
|
|
else -> result = getAnalyzeByJSoup(it).getStringList(rule.rule) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (rule.replaceRegex.isNotEmpty() && result is List<*>) { |
|
|
|
if (rule.replaceRegex.isNotEmpty() && result is List<*>) { |
|
|
@ -192,11 +191,12 @@ class AnalyzeRule(private var book: BaseBook? = null) { |
|
|
|
Mode.Js -> result = evalJS(rule.rule, it) |
|
|
|
Mode.Js -> result = evalJS(rule.rule, it) |
|
|
|
Mode.JSon -> result = getAnalyzeByJSonPath(it).getString(rule.rule) |
|
|
|
Mode.JSon -> result = getAnalyzeByJSonPath(it).getString(rule.rule) |
|
|
|
Mode.XPath -> result = getAnalyzeByXPath(it).getString(rule.rule) |
|
|
|
Mode.XPath -> result = getAnalyzeByXPath(it).getString(rule.rule) |
|
|
|
Mode.Default -> result = if (isUrl && !TextUtils.isEmpty(baseUrl)) { |
|
|
|
Mode.Css -> result = if (isUrl && !TextUtils.isEmpty(baseUrl)) { |
|
|
|
getAnalyzeByJSoup(it).getString0(rule.rule) |
|
|
|
getAnalyzeByJSoup(it).getString0(rule.rule) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
getAnalyzeByJSoup(it).getString(rule.rule) |
|
|
|
getAnalyzeByJSoup(it).getString(rule.rule) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else -> result = rule.rule |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (rule.replaceRegex.isNotEmpty()) { |
|
|
|
if (rule.replaceRegex.isNotEmpty()) { |
|
|
@ -230,7 +230,8 @@ class AnalyzeRule(private var book: BaseBook? = null) { |
|
|
|
Mode.Js -> result = evalJS(rule.rule, it) |
|
|
|
Mode.Js -> result = evalJS(rule.rule, it) |
|
|
|
Mode.JSon -> result = getAnalyzeByJSonPath(it).getObject(rule.rule) |
|
|
|
Mode.JSon -> result = getAnalyzeByJSonPath(it).getObject(rule.rule) |
|
|
|
Mode.XPath -> result = getAnalyzeByXPath(it).getElements(rule.rule) |
|
|
|
Mode.XPath -> result = getAnalyzeByXPath(it).getElements(rule.rule) |
|
|
|
else -> result = getAnalyzeByJSoup(it).getElements(rule.rule) |
|
|
|
Mode.Css -> result = getAnalyzeByJSoup(it).getElements(rule.rule) |
|
|
|
|
|
|
|
else -> result = rule.rule |
|
|
|
} |
|
|
|
} |
|
|
|
if (rule.replaceRegex.isNotEmpty()) { |
|
|
|
if (rule.replaceRegex.isNotEmpty()) { |
|
|
|
result = replaceRegex(result.toString(), rule) |
|
|
|
result = replaceRegex(result.toString(), rule) |
|
|
@ -260,7 +261,8 @@ class AnalyzeRule(private var book: BaseBook? = null) { |
|
|
|
} |
|
|
|
} |
|
|
|
Mode.JSon -> result = getAnalyzeByJSonPath(it).getList(rule.rule) |
|
|
|
Mode.JSon -> result = getAnalyzeByJSonPath(it).getList(rule.rule) |
|
|
|
Mode.XPath -> result = getAnalyzeByXPath(it).getElements(rule.rule) |
|
|
|
Mode.XPath -> result = getAnalyzeByXPath(it).getElements(rule.rule) |
|
|
|
else -> result = getAnalyzeByJSoup(it).getElements(rule.rule) |
|
|
|
Mode.Css -> result = getAnalyzeByJSoup(it).getElements(rule.rule) |
|
|
|
|
|
|
|
else -> result = rule.rule |
|
|
|
} |
|
|
|
} |
|
|
|
if (rule.replaceRegex.isNotEmpty()) { |
|
|
|
if (rule.replaceRegex.isNotEmpty()) { |
|
|
|
result = replaceRegex(result.toString(), rule) |
|
|
|
result = replaceRegex(result.toString(), rule) |
|
|
@ -477,7 +479,7 @@ class AnalyzeRule(private var book: BaseBook? = null) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
enum class Mode { |
|
|
|
enum class Mode { |
|
|
|
XPath, JSon, Default, Js |
|
|
|
XPath, JSon, Default, Js, Regex, Css |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun put(key: String, value: String): String { |
|
|
|
fun put(key: String, value: String): String { |
|
|
|