As far as number of lines go, you can combine the creation of http client,
request, and checking for content in one line. Also, although you made an async
proc, you use waitFor in a for loop, for each future, which will make the
program behave just like doing non async http requests, it will make each http
request sequentially, only start a new one after the future/proc is complete.
To avoid this you can replace the for loop with "waitFor all futures"
<https://nim-lang.org/docs/asyncfutures.html#all%2Cvarargs%5BFuture%5BT%5D%5D>
So the code would look like:
import std/[httpclient, asyncdispatch, strutils]
const urls = @[
"https://www.google.com",
"https://www.yahoo.com"]
proc getContent(url: string): Future[void] {.async.} =
echo url & " " & $(await
newAsyncHttpClient().getContent(url)).contains("tag")
var futures : seq[Future[void]]
for url in urls: futures.add(getContent(url))
waitFor all futures
Run