This commit is contained in:
2023-11-24 02:56:21 +00:00
parent c8d7456e0c
commit 27ae99afeb
2 changed files with 50 additions and 6 deletions

View File

@@ -21,6 +21,13 @@ using HTTP, JSON3
```
"""
function wikisearch(phrase::T) where {T<:AbstractString}
phrase = phrase[1] == " " ? phrase[2:end] : phrase
# prepare input phrase
if occursin("\"", phrase)
phrase = GeneralUtils.getStringBetweenCharacters(toolinput, "\"", "\"")
end
phrase = replace(phrase, "\n"=>"")
url = "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&titles=$(replace(phrase, " " => "%20"))&exintro=1&explaintext=1"
response = HTTP.get(url)
json_data = JSON3.read(String(response.body))