Giter Site home page Giter Site logo

youngcet / websitedownloader Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7 KB

This PHP class, `WebsiteDownloader`, is designed to download various assets (HTML files, CSS files, JavaScript files, images, etc.) from a given website. It provides methods to download specific types of assets or all assets at once.

License: MIT License

PHP 100.00%
downloader website website-downloader websitedownloader

websitedownloader's Introduction

Website Downloader

This PHP class, WebsiteDownloader, is designed to download various assets (HTML files, CSS files, JavaScript files, images, etc.) from a given website. It provides methods to download specific types of assets or all assets at once.

Usage

Instantiate the WebsiteDownloader class by providing the required parameters: the domain of the website to download from and the output directory where the downloaded files will be saved.

$downloader = new WebsiteDownloader([
    'domain' => 'https://example.com',
    'output_dir' => '/path/to/output/directory'
]);

Methods

  • download($asset): Downloads the specified type of asset. If no asset type is provided, it downloads all assets. Supported asset types are 'html', 'css', 'js', and 'img'.

  • downloadAssetFromURL($url): Downloads a specific asset from the provided URL.

Example

download($asset);

Downloading a specified type of asset from the given domain.

try {
    // downloads all assets (html, css, js, images, etc)
    $downloader->download();

    // download html
    $downloader->download('html');

    // download js
    $downloader->download('js');
    
    // download css (this will include favicons if found)
    $downloader->download('css');

    // download images
    $downloader->download('img');

} catch (InvalidArgumentException $e) {
    echo "Error: " . $e->getMessage();
}

downloadAssetFromURL($href);

Downloads a specific asset from the provided URL

// downloads the index.html file
// you can pass any file in the url to download such as images, js, css, etc
$downloader->downloadAssetFromURL('https://example.com/index.html');

Requirements

  • PHP 7.0 or higher
  • cURL extension enabled

Note

  • This class uses cURL to download files from the website. Make sure cURL extension is enabled in your PHP configuration.
  • Be cautious while using this class to avoid downloading files from unauthorized websites or violating terms of service.
  • Downloading files from a website may not always be possible due to restrictions set by the website owner or technical limitations in its design.

Author

This PHP class was created by Yung Cet (Cedric Maenetja).

License

This PHP class is released under the MIT License. See the LICENSE file for details.

websitedownloader's People

Contributors

youngcet avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.