dicr/yii2-google-wdr

使用 WebDriver 驱动程序通过 Google 进行 Yii2 搜索

安装: 0

依赖项: 0

建议者: 0

安全: 0

星标: 1

分支: 0

类型:yii2-extension

1.0.3 2021-02-03 20:57 UTC

This package is auto-updated.

Last update: 2024-08-29 05:40:36 UTC


README

组件配置

$config = [
    'components' => [
        'googleWdr' => [
            'class' => dicr\google\wdr\GoogleWdr::class,
            'driverUrl' => 'url web-драйвера'
        ]
    ]
];

使用方法

use dicr\google\wdr\GoogleWdr;
use dicr\google\wdr\GoogleWdrRequest;

/** @var GoogleWdr $googleWdr модуль */
$googleWdr = Yii::$app->get('googleWdr');

/** @var GoogleWdrRequest $req запрос создания задачи */
$req = $googleWdr->searchRequest([
    'query' => 'мыльная опера'
]);

// выводим результаты
foreach ($req->results as $res) {
    echo 'URL: ' . $res['url'] . "\n";
    echo 'Title: ' . $res['title'] . "\n";
}