优化
This commit is contained in:
@@ -3,6 +3,7 @@ package io.legado.app.model.analyzeRule
|
|||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import org.jsoup.parser.Parser
|
||||||
import org.jsoup.select.Collector
|
import org.jsoup.select.Collector
|
||||||
import org.jsoup.select.Elements
|
import org.jsoup.select.Elements
|
||||||
import org.jsoup.select.Evaluator
|
import org.jsoup.select.Evaluator
|
||||||
@@ -17,10 +18,13 @@ class AnalyzeByJSoup(doc: Any) {
|
|||||||
private var element: Element = parse(doc)
|
private var element: Element = parse(doc)
|
||||||
|
|
||||||
private fun parse(doc: Any): Element {
|
private fun parse(doc: Any): Element {
|
||||||
return when (doc) {
|
if (doc is Element) {
|
||||||
is Element -> doc
|
return doc
|
||||||
else -> Jsoup.parse(doc.toString())
|
|
||||||
}
|
}
|
||||||
|
if (doc.toString().startsWith("<?xml", true)) {
|
||||||
|
return Jsoup.parse(doc.toString(), Parser.xmlParser())
|
||||||
|
}
|
||||||
|
return Jsoup.parse(doc.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import androidx.annotation.Keep
|
|||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
import org.jsoup.nodes.TextNode
|
import org.jsoup.nodes.TextNode
|
||||||
|
import org.jsoup.parser.Parser
|
||||||
import org.jsoup.select.Elements
|
import org.jsoup.select.Elements
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
@@ -13,10 +14,13 @@ class AnalyzeByXPath(doc: Any) {
|
|||||||
private var element: Element = parse(doc)
|
private var element: Element = parse(doc)
|
||||||
|
|
||||||
private fun parse(doc: Any): Element {
|
private fun parse(doc: Any): Element {
|
||||||
return when (doc) {
|
if (doc is Element) {
|
||||||
is Element -> doc
|
return doc
|
||||||
else -> Jsoup.parse(doc.toString())
|
|
||||||
}
|
}
|
||||||
|
if (doc.toString().startsWith("<?xml", true)) {
|
||||||
|
return Jsoup.parse(doc.toString(), Parser.xmlParser())
|
||||||
|
}
|
||||||
|
return Jsoup.parse(doc.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun getElements(xPath: String): Elements? {
|
internal fun getElements(xPath: String): Elements? {
|
||||||
|
|||||||
Reference in New Issue
Block a user