Ji
Ji copied to clipboard
XPath error : Invalid expression
我之前用的是Kanna,运行都正常,但是有少许内存泄漏。 换Ji库后,macOS下运行很完美,但是相同代码到Linux上所有XPath都会报错。 XPath error : Invalid expression
@huhuegg 可以把code snippet贴出来吗?或者你的xpath是什么?
func testXPath() {
HttpHandler.doGetRequest(urlStr: "http://www.luoxia.com/fanghua/69911.htm") { (data) in
guard let data = data else {
print("Http request failed")
return
}
guard let doc = Ji(htmlData: data, encoding: .utf8) else {
print("Ji init failed")
return
}
let listXpath = "//*[@id='pagewrap']/article"
guard let rootNode = doc.xPath(listXpath)?.first else {
print("listXpath not found!(\(listXpath))")
return
}
print(rootNode.content)
}
}
操作系统: ubuntu16.04 swift: 4.1 Ji: .package(url: "https://github.com/honghaoz/Ji.git", from: "2.1.0") error:
XPath error : Invalid predicate
XPath error : Invalid expression
listXpath not found!(//*[@id='pagewrap']/article)