AlamofireSwiftSoup
Installation
The recommended approach for installing AlamofireSwiftSoup is via the CocoaPods package manager, as it provides flexible dependency management and dead simple installation.
Install CocoaPods if not already available:
$ [sudo] gem install cocoapods
$ pod setup
Edit your Podfile and add AlamofireSwiftSoup
:
$ edit Podfile
platform :ios, '12.0'
pod 'AlamofireSwiftSoup'
Install into your Xcode project:
$ pod install
Usage
import AlamofireSwiftSoup
AF.request("https://httpbin.org/").responseSwiftSoupHTML { dataResponse in
switch dataResponse.result {
case .failure(let error):
debugPrint(error)
case .success(let document):
if let scriptElement = try? document.select("title").first(), let titleString = try? scriptElement.html() {
debugPrint(titleString)
}
}
}