在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:tid-kijyun/Kanna开源软件地址:https://github.com/tid-kijyun/Kanna开源编程语言:Swift 91.4%开源软件介绍:Kanna(鉋)Kanna(鉋) is an XML/HTML parser for cross-platform(macOS, iOS, tvOS, watchOS and Linux!). It was inspired by Nokogiri(鋸). Features
Installation for Swift 5CocoaPodsAdd the following to your use_frameworks!
pod 'Kanna', '~> 5.2.2' CarthageAdd the following to your
For xcode 11.3 and earlier, the following settings are required.
Swift Package Manager
// macOS: For xcode 11.3 and earlier, the following settings are required.
$ brew install libxml2
$ brew link --force libxml2
// Linux(Ubuntu):
$ sudo apt-get install libxml2-dev
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "YourProject",
dependencies: [
.package(url: "https://github.com/tid-kijyun/Kanna.git", from: "5.2.2"),
],
targets: [
.target(
name: "YourTarget",
dependencies: ["Kanna"]),
]
) $ swift build Note: When a build error occurs, please try run the following command: // Linux(Ubuntu)
$ sudo apt-get install pkg-config Manual Installation
Installation for swift 4Installation for swift 3Synopsisimport Kanna
let html = "<html>...</html>"
if let doc = try? HTML(html: html, encoding: .utf8) {
print(doc.title)
// Search for nodes by CSS
for link in doc.css("a, link") {
print(link.text)
print(link["href"])
}
// Search for nodes by XPath
for link in doc.xpath("//a | //link") {
print(link.text)
print(link["href"])
}
} let xml = "..."
if let doc = try? Kanna.XML(xml: xml, encoding: .utf8) {
let namespaces = [
"o": "urn:schemas-microsoft-com:office:office",
"ss": "urn:schemas-microsoft-com:office:spreadsheet"
]
if let author = doc.at_xpath("//o:Author", namespaces: namespaces) {
print(author.text)
}
} DonationIf you like Kanna, please donate via GitHub sponsors or PayPal. LicenseThe MIT License. See the LICENSE file for more information. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论