Giter Site home page Giter Site logo

webprobe's Introduction

webProbe

PHP Library to send probes on missions to perform actions on a websites.

How does it work

LaunchPad

Execute missions.

it takes a Mission as argument for the constructor. The method launch() execute the mission through the method execute() and return an object of type MissionResult.

$launchPad =  new LaunchPad($mission);
$missionResult = $launchPad->launch();

MissionResult

class MissionResult
   {
   
       public const OK_STATUS_CODE = 200;
   
       /** @var int */
       private $statusCode;
   
       /** @var string */
       private $result; 
       ...

Mission

A Class extending the BaseMission needs to implement the abstract method execute() This method receive the results from the probe and it can manipulate and process the raw data.

A Mission as as constructor arguments the MissionSetting and the Probe objects.

public function __construct(MissionSetting $missionSetting, Probe $probe);

Mission settings

A MissionSetting is an object which constructor takes as argument an array of params stored in the object and that can be used during execution of the mission if neede. Params can be empty.

class MissionSetting
   {
       /** @var array */
       private $params;
   
       public function __construct(array $params = [])
       ...

Probe

A probe is an object able to analyse a website and needs to be created implementing the interface Probe It is instantiated using ProbeSetting as argument The method run() needs to return an object of type ProbeResult

interface Probe
{
    public function __construct(ProbeSetting $probeSetting);
    public function run(): ProbeResult;
}

ProbeResult

class ProbeResult
{

    public const OK_STATUS_CODE = 200;

    /** @var string */
    public $statusCode;

    /** @var string */
    public $errorMessage;

    /** @var string */
    public $payload;

}

ProbeSetting

An object of type ProbeSetting is instantiated with the string URL of the website page to analyse.

/** @var string */
    private $url;

    public function __construct(string $url)
    {
        $this->url = $url;
    }

Libraries

The DiscoveryLibrary can be extended and used in the Probe in order to collect information from the Page. Available in webProbe/Libraries are

  • CanonicalDiscoveryLibrary
  • PictureDiscoveryLibrary
  • PriceDiscoveryLibrary (dev)
  • TitleDiscoveryLibrary
  • DomainDiscoveryLibrary

ScraperHelper and PriceScraperHelper

In order to extend the capacity of DisoveryLibrary there are static methods available in ScraperHelper and PriceScraperHelper with dedicated method to read the page information.

Clarification around Libraries and ScraperHelper

A library is a high-level Class with dedicated method in the context of the information. E.g.

  • method findHTMLTitle() of TitleDiscoveryLibrary is an explicit method, the context is to read the value contained in the web page title.
  • in order to get this information, makes use (through the DiscoveryLibrary) of the method ScraperHelper::readBetween a static operational method reading inside a tag, and used in this context for <title></title>

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.