making fully dynamic snippets :D
This commit is contained in:
11
config.lua
11
config.lua
@@ -1,19 +1,22 @@
|
||||
local function duckduckgo(query)
|
||||
-- local result = vs.fetchUrl("https://lite.duckduckgo.com/lite?q=" .. query)
|
||||
local result = idx.fetchUrl("https://lite.duckduckgo.com/lite?q=" .. query)
|
||||
|
||||
-- local htmlTree = vs.decodeHtml(result)
|
||||
local htmlTree = idx.decodeHtml(result)
|
||||
|
||||
local selector = {
|
||||
source = "title",
|
||||
title = "tbody tr td a.result-link",
|
||||
snippet = "tbody tr td.result-snippet",
|
||||
url = "tbody tr td a.result-link/href",
|
||||
}
|
||||
|
||||
return { title = "something", some = "some" }
|
||||
local selected = htmlTree:scrape(selector)
|
||||
|
||||
return selected
|
||||
end
|
||||
|
||||
local function ddgBuilder(values)
|
||||
return "<p>" .. values.some .. "</p>"
|
||||
return "<p>" .. values.title .. "</p>"
|
||||
end
|
||||
|
||||
SearchEngines = { duckduckgo = { grabber = duckduckgo, builder = ddgBuilder } }
|
||||
|
||||
Reference in New Issue
Block a user