Select dois from response

This commit is contained in:
Yannick Reiß 2024-02-18 19:32:16 +01:00
parent 26622ecefc
commit c45dec6291
No known key found for this signature in database
GPG Key ID: 5A3AF456F0A0338C
1 changed files with 24 additions and 3 deletions

View File

@ -11,12 +11,33 @@ function M.lookup()
-- Execute the curl command and capture its output
local handle = io.popen(command)
local response = handle:read("*a")
local response = ""
if handle ~= nil then
response = handle:read("*a")
handle:close()
else
response = ""
end
-- select doi links from response
local b = 1
local doi_links = {}
while true do
local x, y = response:find("//doi/[a-zA-Z]+/10.[0-9]+/[0-9.]+/gm", b, false)
-- stop if no further occurrences are found
if x == nil or y == nil then
break
end
-- save substring to doi_links
doi_links:insert(response:sub(x, y))
b = y
end
print("Keywords: " .. keywords)
print("URL: " .. url)
print("Response: " .. response)
print("links: " .. doi_links)
end
return M