|
|
|
@ -123,11 +123,10 @@ class AnalyzeRule(private var book: BaseBook? = null) { |
|
|
|
|
if (rule.rule.isNotEmpty()) { |
|
|
|
|
when (rule.mode) { |
|
|
|
|
Mode.Js -> result = evalJS(rule.rule, result) |
|
|
|
|
Mode.JSon -> result = |
|
|
|
|
getAnalyzeByJSonPath(it).getStringList(rule.rule) |
|
|
|
|
Mode.XPath -> result = |
|
|
|
|
getAnalyzeByXPath(it).getStringList(rule.rule) |
|
|
|
|
else -> result = getAnalyzeByJSoup(it).getStringList(rule.rule) |
|
|
|
|
Mode.JSon -> result = getAnalyzeByJSonPath(it).getStringList(rule.rule) |
|
|
|
|
Mode.XPath -> result = getAnalyzeByXPath(it).getStringList(rule.rule) |
|
|
|
|
Mode.Css -> result = getAnalyzeByJSoup(it).getStringList(rule.rule) |
|
|
|
|
else -> result = rule.rule |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
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.JSon -> result = getAnalyzeByJSonPath(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) |
|
|
|
|
} else { |
|
|
|
|
getAnalyzeByJSoup(it).getString(rule.rule) |
|
|
|
|
} |
|
|
|
|
else -> result = rule.rule |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (rule.replaceRegex.isNotEmpty()) { |
|
|
|
@ -230,7 +230,8 @@ class AnalyzeRule(private var book: BaseBook? = null) { |
|
|
|
|
Mode.Js -> result = evalJS(rule.rule, it) |
|
|
|
|
Mode.JSon -> result = getAnalyzeByJSonPath(it).getObject(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()) { |
|
|
|
|
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.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()) { |
|
|
|
|
result = replaceRegex(result.toString(), rule) |
|
|
|
@ -477,7 +479,7 @@ class AnalyzeRule(private var book: BaseBook? = null) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
enum class Mode { |
|
|
|
|
XPath, JSon, Default, Js |
|
|
|
|
XPath, JSon, Default, Js, Regex, Css |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun put(key: String, value: String): String { |
|
|
|
|