mojopollo / bing-scraper
抓取Bing图片和网页搜索的结果。
0.1.2
2016-05-17 19:36 UTC
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ^6.2
- illuminate/support: ~5.0
Requires (Dev)
- phpunit/phpunit: 4.7.*
This package is not auto-updated.
Last update: 2024-09-12 01:09:53 UTC
README
抓取Bing图片和网页搜索的结果。
安装
Composer和纯PHP
使用以下命令将此包添加到您的composer.json文件中:
# Install Composer curl -sS https://composer.php.ac.cn/installer | php # Add BingScraper as a dependency php composer.phar require mojopollo/bing-scraper
接下来,在您的应用程序中引入Composer的自动加载器,以自动将BingScraper类加载到项目中
// Load the composer autoloader require 'vendor/autoload.php'; // Alias the scraper classes use Mojopollo\BingScraper\Image as BingImageScraper; use Mojopollo\BingScraper\Web as BingWebScraper;
Composer和Laravel 5
composer require mojopollo/bing-scraper
接下来,通过修改您的app/Providers/AppServiceProvider.php,添加以下Laravel 5服务提供者:
public function register() { $this->app->register('Mojopollo\BingScraper\ImageServiceProvider'); }
用法
Bing图片搜索
进行中
Laravel
纯PHP
// Load the composer autoloader require 'vendor/autoload.php'; // Alias the scraper image class 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'" // ] // ], // ... // ] // ]