TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Oct 2016 |
Maintained by Cătălin Stan.
A simple utility for getting the fully rendered content of a web-page, as the browser sees it, after all JavaScript, CSS and images have loaded and executed, either as a PNG or HTML text.
Install using CocoaPods by adding this line to your Podfile:
use_frameworks!
target 'MyApp' do
pod 'CSWebShot'
end
The example below fetches a PNG rendering of a webpage and generates an NSImage
object from the returned data.
let url = URL(string: "https://criollo.io/")!
CSWebShot(url: url).webshot { (action, data, error) in
if (error != nil) {
print ("An error has occurred: \(error?.localizedDescription)")
return
}
let image = NSImage(data: data!)
}
The example below fetches the rendered HTML content of a webpage and generates a String
object from the returned data.
let url = URL(string: "https://criollo.io/")!
CSWebShot(url: url).renderedHTML { (action, data, error) in
if (error != nil) {
print ("An error has occurred: \(error?.localizedDescription)")
return
}
let html = String(data: data!, encoding: String.Encoding.utf8)
}
Check out the complete documentation on CocoaDocs.