try:
src = soup.find("div", {"id": "image-block"})
except AttributeError:
continue
It works great, but the problem is:
when I get one url it's ok, but when I receive five urls they come inside the same variable.
I need to specify 10 variables:
- img1
- img2
- img3
- ...
If BS finds only 1 url it puts it into url 1, but if BS finds 3 urls, it separates them and puts them into different variables.
Thanks you for your help
EDIT
Thanks you so much for your help but sometime i have 1 image to get and sometime 8.
So i get this :
var1, var2, var3, var4, var5,var6, var7, var8 = soup.find_all("div", {"id": "image-block"})
ValueError: not enough values to unpack (expected 8, got 1)
But if i put : var1 = soup.find_all("div", {"id": "image-block"}) it's works but put all in var1
My problem is that i don't know how much image i have to get on each loop.
Thank you again for you time.