CSWebShot 1.0.1

CSWebShot 1.0.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Oct 2016

Maintained by Cătălin Stan.


Downloads

Total3
Week0
Month0

Installs

Apps1
powered by Segment

GitHub

Stars0
Watchers1
Forks0
Issues0
Contributors1
Pull Requests0

Code

Files2
LOCLines of Code 130


CSWebShot 1.0.1

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.

Installation

Install using CocoaPods by adding this line to your Podfile:

use_frameworks!

target 'MyApp' do
  pod 'CSWebShot'
end

Getting a PNG rendering of a web page

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!)
}

Getting the rendered HTML content of the page

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)
}

What’s Next

Check out the complete documentation on CocoaDocs.