developer53 / google-search

爬取google.com或google.ae搜索引擎的结果并提取一组关键词的元数据。

1.0.5 2022-07-04 11:49 UTC

This package is auto-updated.

Last update: 2024-09-04 16:27:27 UTC


README

抓取谷歌搜索结果。

功能

  • 从google.ae或google.com获取搜索请求

要求

  • PHP版本7.2或更高

简易安装

使用composer安装

要使用Composer安装,只需要求此包的最新版本。

composer require developer53/google-search

确保加载Composer的autoload文件。

// somewhere early in your project's loading, require the Composer autoloader
// see: https://getcomposer.org.cn/doc/00-intro.md
require './vendor/autoload.php';

快速开始

只需设置搜索引擎并传递查询字符串作为数组

// goto below link and create API. If default not works.
// https://rapidapi.com/marcelinhov2/api/google-search1/

// instantiate and use the SearchEngine class
$client = new \SearchEngine\SearchEngine(); // Pass api key as a parameter or leave empty to use default API.

// set enginge name google.ae or google.com
$client->setEngine('google.ae');

// pass query string as an array
$results = $client->search(['shed stores dubai']);

// Output Results
echo '<pre>';
print_r($results);
echo '</pre>';