How to save images from internet to file


I want to save image from internet to file. I cannot find image related information.

Below is my example to get page and extract image block.
Example site is my own site, using free theme.

using HTTP, Gumbo, Cascadia

url = ""

r = HTTP.get(url)

h = parsehtml(String(r.body))

body = h.root[2]

images = eachmatch(Selector("img"), body)



So I want to save image
to file.

I added dash to file name to prevent image to show here.


Get the image URL:

img_attrs = attrs(img)
img_src = img_attrs["src"]

Then download it:

using Downloads
download(img_src, "img.jpg")

This might help to get you started?

Yes it helped !
Thank you very much for quick answer !

Last lines of code if someone would need:

img_link = images[5].attributes["src"]

img_name = split(img_link, '/')[end]

download(img_link, img_name)