open-source Public Repo active ★ 2

Cctv Direct

Codename: #CctvDirect · Repository: immachakata/cctv-direct

Primary LanguageHTML
Last UpdatedJun 26, 2023
CreatedJun 26, 2023
Branch / Sizemain · 27 KB

Executive Summary

A small php package I was tasked with making to scrap data from this website.

GitHub Codebase Language Breakdown

HTML93.7%
PHP6.3%

Repository Documentation (README.md)

Fetched from GitHub

PHP Data Miner

Fetches data from a certain website.

Installation

Clone or Download the code and install the dependencies using Composer composer install

Usage

Include the autoload file and setup and headers.

use CctvDirect\Scrapper;

include __DIR__ . "/vendor/autoload.php";

header('Content-Type: application/json');

# localhost scrapping

The following scrapes data from the file in the bin folder

$results  = array();
$scrapper = new Scrapper();
$scrapper->scrape('http://localhost/bin/dahua-analog-hd-cctv-cameras.htm');

// ? localhost demo scrapping 
$collection = $scrapper->collection;
$results    = array(
    'title' => $collection->getTitle(),
    'category_slug' => $collection->getCategorySlug(),
    'products' => $collection->getProducts(),

    // 'collections' => $collection->getCollections(),
);
// ? print results
echo json_encode($results, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

# live scrapping

In this example, we get the collections from the file in the bin, then scrap products from the live site.

$collections = $scrapper->collection->getCollections();

foreach ($collections as $collectionUrl) {
    $scrapper->scrape($collectionUrl);
    $results[$scrapper->collection->getCategorySlug()] = array(
        'title' => $scrapper->collection->getTitle(),
        'products' => $scrapper->collection->getProducts()
    );
}

Recent Repository Commits

5ad2f6bdoc: minor changes
Jun 26, 2023
bcd71a4refactor: fetch from server by default
Jun 26, 2023
188ce19feat: use custom fetch function
Jun 26, 2023
ee36582fix: null values on images
Jun 26, 2023
7687e0afix: null values on image alt and title
Jun 26, 2023

Stack & Repository Topics

HTML #oss #portfolio #web-scraping

Related Work & Projects

All projects →