首先要先 pod Kanna
在 ViewController
import Kanna
override func viewDidLoad() {
super.viewDidLoad()
let loginurl = "https://translate.google.com/"
if let doc = try? HTML(html: loginurl, encoding: .utf8) {
print(doc.title)
// Search for nodes by CSS
for link in doc.css("body, script") {
print(link.text)
print(link["src"])
}
}
}