Skip to content
Andresito de Guzman edited this page Jul 21, 2017 · 2 revisions

Kunin

Introduction

This is a library for PHP that you can use to extract important information from a webpage.

Initialization

// Require the File
require("kunin.php");

// Create an object for one url
$url = "https://github.com/andresitodeguzman";
$obj = new kunin($url);

Sample Code Usage

// Require file
require("kunin.php");

// Declare URL and Create Object
$url = "https://github.com/andresitodeguzman";
$obj = new kunin($url);

// Create Preset Values in case values are empty
$title = "Unknown Title";
$description = "No description provided";

// Get Title and Check if set
$t = $obj->getTitle();
if(isset($t)){
    $title = t;
}

// Get Description and Check if set
$d = $obj->value("description");
if(isset($d)){
    $description = $d;
}

// Prepare by creating an array
$array = array(
    "title"=>"$title",
    "description"=>"$description"
);

// Encode array into json and echo
echo json_encode($array);

Get the Title

// getTitle()
$title = $obj->getTitle();

Get a Value of a Certain Meta-Tag Property

// value(String $keyword)
$value = $obj->value("description"); // Returns description of site

Get Images

Returns an array of images from the site

// getImages()
$images = $obj->getImages();