Dears,
is there any way to optimise this little piece of async code to make faster
response and shorter code maybe? URLs and search string being provided only for
the researching purpose.
import std/[httpclient, asyncdispatch, strutils]
const urls = @[
"https://www.google.com",
"https://www.yahoo.com",
]
proc getContent(url: string): Future[void] {.async.} =
let client = newAsyncHttpClient()
let content = await client.getContent(url)
echo url & " " & $content.contains("tag")
var futures : seq[Future[void]]
for url in urls:
futures.add(getContent(url))
for future in futures:
waitFor future
Run
I'm mostly curious about for loops.
Thanks