I want to download a bunch of images with Beautifulsoup. First, I get the url of images. Then I try to download the iamges with requests. It works for the most images, but for some images, it creates an image file, but the file size is much smaller than the others and the file is empty. I could open the url on the browser, the url is correct. My suspect is that the image is saved, before it is completely loaded, but I don't know how to solve it.
In the example, I could download the first image, but not the second.
img2=['https://yda.11dmh.com/images/p/d4/ed/4e7546a015068d305969a38de43c.jpg',
'https://n7a.91dmh.com/images/p/59/7f/eaa52c0e912d03e0f40892baad33.jpg']
for i1 in range(len(img2)):
r1=requests.get(img2[i1])
with open(f'test{i1}.jpg', "wb+") as f_out:
f_out.write(r1.content)