-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
70 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
-- -- JSON engine for Searched | ||
-- -- Licensed MIT. | ||
-- -- (c) 2024 Dragynfruit | ||
|
||
add_engine('qwant', function(client, query, opts) | ||
local url = Url.from_template('https://api.qwant.com/v3/search/web?locale=en_us&count=10&p={page}&q={query}', { | ||
query = query.query, | ||
page = tostring(query.page), | ||
}):string() | ||
|
||
local res = client:get(url, {}) | ||
local data = parse_json(res) | ||
local mainline = data.data.result.items.mainline | ||
|
||
local results = {} | ||
local i = 1 | ||
for _, item in ipairs(mainline) do | ||
if item.type == 'web' then | ||
for _, result in ipairs(item.items) do | ||
results[i] = { | ||
title = result.title, | ||
url = result.url, | ||
general = { | ||
snippet = result.desc, | ||
}, | ||
} | ||
i = i + 1 | ||
end | ||
end | ||
end | ||
|
||
return results | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters