PHP code example of apto1 / translate-scrapper

1. Go to this page and download the library: Download apto1/translate-scrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

apto1 / translate-scrapper example snippets


/**
* The urls array of the content to be crawled
* pageId=>['en'=>'url','gr'=>'url']
*/
const URLS = [
    13 => [
        'en'	=> 'https://herema.gr/who-we-are/our-mandate/',
        'gr'	=> 'https://herema.gr/el/who-we-are/our-mandate/',
    ],
    14 => [
        'en'	=> 'https://herema.gr/who-we-are/our-transformation/',
        'gr'	=> 'https://herema.gr/el/who-we-are/our-transformation/',
    ],
];

/**
* Just initialize the class and everything will be done automatically
*/
$scrapper = new Scrapper(URLS);

/**
* There are some available methods for debugging
*/
//The URLS array
$scrapper->getUrls();
//The dictionary array
$scrapper->getFiles();
//Performance timings for curl,parsing and writing
$scrapper->getPerformance();
//The scrapped sanitzed content
$scrapper->getScrappedContent();
//The original content
$scrapper->getUrlContent();

/**
* Create a new instance of the Search class
* by passing the language
* PS. Leave blank contructor for en languange
*/
$dictionary = new Dictionary('gr');

/**
* Search for a word using the ->search() method
*/
$dictionary->search('Με πυξίδα την πεποίθηση ότι η εταιρεία');

/**
* Retrieve the results using the ->getResults() method
*/
$res = $dictionary->getResult();

/**
* There are some available methods for debugging
*/
//Performance timings for parsing and searching
$dictionary->getPerformance();
//The dictionary array
$dictionary->getDictionary()