Latest 1.0.1
Homepage https://github.com/thecatalinstan/CSWebShot
License MIT
Platforms osx 10.8, requires ARC
Authors

Version Status Platform Carthage compatible MIT License

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.

Latest podspec

{
    "name": "CSWebShot",
    "version": "1.0.1",
    "license": "MIT",
    "summary": "A library for getting screenshots and rendered HTML source code of webpages.",
    "homepage": "https://github.com/thecatalinstan/CSWebShot",
    "authors": {
        "Cu0103tu0103lin Stan": "[email protected]"
    },
    "social_media_url": "http://twitter.com/catalinstan",
    "source": {
        "git": "https://github.com/thecatalinstan/CSWebShot.git",
        "tag": "1.0.1"
    },
    "module_name": "CSWebShot",
    "source_files": "CSWebShot/*.{h,m}",
    "public_header_files": "CSWebShot/CSWebShot.h",
    "platforms": {
        "osx": "10.8"
    },
    "osx": {
        "frameworks": "Foundation"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This