How to save images from internet to file

Hi,

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 = "http://www.webkurimas.online/demo2/"

r = HTTP.get(url)

h = parsehtml(String(r.body))

body = h.root[2]

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

images[5]

REPL:
HTMLElement{:img}:

So I want to save image
http://www.webkurimas.online/demo2/wp-content/uploads/2020/06/black-wooden-coffee-table-near-white-couch-1.jpg_
to file.

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

Thanks,
Edvard

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)