honghaoz / Ji

Ji (戟) is an XML/HTML parser for Swift
MIT License
824 stars 65 forks source link

可以根据class来找到html元素吗? #43

Closed kakaxicm closed 7 years ago

kakaxicm commented 7 years ago

可以根据class来找到html元素吗?

honghaoz commented 7 years ago

可以利用xpath来查询。

比如:

let doc = Ji(htmlURL: URL(string: "YOUR_URL_STRING")!)
let node = doc?.xPath("div[@class='YOUR_CLASS_NAME']")?.first
print("title: \(node?.content)")