Hi,
So, for the past few days I’ve been trying to do the following (included usage example);
import httpclient
const filePath = “somePathToSaveImages”
# pastebinUrl is an http url to a list of urls
var client = newHttpClient()
let content = client.getContent(pastebinUrl)
# each link in links is an https url to an image
let links = content.split(“\n”)
for i, link in links:
client.downloadFile(link, filePath & $i & “.png”)
I may be missing some stuff in the example, as I wrote it on my phone, but that’s the general idea.
All of the links work when I explicitly write them as a string in the program itself, but I get a 404 Bad Request when I try to get the links and iterate over them automatically.
Any help is appreciated, as well as tips to improve my code. Just starting with Nim, coming from 8-9 years of Python.
Since it's return 404 it means there's some error in your url string. It's better to check the string url first.
I've done like what you did and the executable is still working. Wrote the executable one year ago and still working correctly
You can use strformat then fmt"some literal string with {variables} inside {1+1}"
Kinda like Python3 F-Strings.
content.split(“\n”) I think can be content.splitLines