PHP code example of mojopollo / bing-scraper

1. Go to this page and download the library: Download mojopollo/bing-scraper 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/ */

    

mojopollo / bing-scraper example snippets


// Load the composer autoloader
se Mojopollo\BingScraper\Image as BingImageScraper;
use Mojopollo\BingScraper\Web as BingWebScraper;

public function register()
{
    $this->app->register('Mojopollo\BingScraper\ImageServiceProvider');
}

// Load the composer autoloader
ss
use Mojopollo\BingScraper\Image as BingImageScraper;

// Instantiate image scraper class
$bingImageScraper = new BingImageScraper;

// Set options and scrape
// see "options" section in this readme for all available options
$bingImageScraper
    ->query('sloth smiling')
    ->safe('strict')
    ->type('photograph')
    ->scrape();

// This is what you get back

// [
//     'meta' => [
//         'status' => 200,
//         'error' => null,
//         'count' => 20
//     ],
//     'results' => [
//         [
//             'url' => 'http://example.com/my-sloths',
//             'image' => 'http://example.com/my-sloths/images/sloth-smiling.jpg',
//             'width' => '1900',
//             'height' => '600',
//             'format' => 'jpeg',
//             'meta' => [
//               'ns' => 'images',
//               'k' => '3599',
//               'mid' => 'FXDP1BZ7EHN12BL7O2QVTZOXO0UYTGSRDHKF1COX',
//               'cid' => 'zAN2dtE2',
//               'md5' => '49f68a5c8493ec2c0bf489821c21fc3b',
//               'tid' => 'OIP.O6qE4AQEPKPewVVT746gVXk6dqMNIsQEybC',
//               'docid' => '329832932856960383',
//               'tft' => '45',
//               'mw' => '634',
//               'mh' => '1024',
//               'thH' => '300',
//               'thW' => '18'"
//             ]
//         ],
//         ...
//     ]
// ]

bash
# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add BingScraper as a dependency
php composer.phar 
app/Providers/AppServiceProvider.php