[GoogleSearch] feat: add verbatim option (#2858)

The verbatim option is the same as wrapping the query in quotes e.g. "rss-bridge".
This commit is contained in:
Dag 2022-06-24 11:18:27 +02:00 committed by GitHub
parent 1cfcacbbeb
commit 92782e6c34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -13,7 +13,12 @@ class GoogleSearchBridge extends BridgeAbstract {
'name' => 'keyword', 'name' => 'keyword',
'required' => true, 'required' => true,
'exampleValue' => 'rss-bridge', 'exampleValue' => 'rss-bridge',
) ),
'verbatim' => array(
'name' => 'Verbatim',
'type' => 'checkbox',
'title' => 'Use literal keyword(s) without making improvements',
),
)); ));
public function collectData(){ public function collectData(){
@ -78,7 +83,8 @@ class GoogleSearchBridge extends BridgeAbstract {
'hl' => 'en', 'hl' => 'en',
'num' => '100', // get 100 results 'num' => '100', // get 100 results
'complete' => '0', 'complete' => '0',
'tbs' => 'qdr:y,sbd:1' // in past year, sort by date // in past year, sort by date, optionally verbatim
'tbs' => 'qdr:y,sbd:1' . ($this->getInput('verbatim') ? ',li:1' : ''),
]; ];
return sprintf('https://www.google.com/search?%s', http_build_query($queryParameters)); return sprintf('https://www.google.com/search?%s', http_build_query($queryParameters));
} }