Download file using R

I am trying to download a file using download.file

download.file("https://cdn.countryflags.com/download/china/flag-png-xl.png", "x.png")

But it is not working.
The file is located in https://www.countryflags.com/en/china-flag-image.html
Thanks

But when I put

https://cdn.countryflags.com/download/china/flag-png-xl.png

As a url for my webrowser, I dont get a single image, I get redirected to a page full of flags, I would guess that download.file() experiences the same

I think you are saying that you agree with me.

Try to open the url


and try to copy url of any flage in png or jpg and paste in the browser... it won't work

Yes ..... totally agree.
I am wondering if rvest package can help me... since I want to download all flags

maybe try a different service