Web api related

why do we mention attrs[‘src’] . why can’t we just use findAll for src ?

Hey,

findall() finds all the elements/tags in a HTML page like <a>, <ul>, <div>. But src is not an element/tag that’s why we can’t do it, src is an attribute of img tag therefore, you can see in video, first, we got all the relevant images, and then accessing the src attribute.

Note : Not all images on the page, not doing this findall(img)

Hope this clears your doubt,

Thanks :slight_smile:,

Thank you so much. Also, I wanted to know that I used article_element=article_soup.findAll(‘img’)
because in the html code of the website , the article tag was not there. Is it alright to do so?
it worked fine and for fetching all the images in separate files, I iterated the code by using range() for as many images I wanted to save.

Yes, this is fine as well.
Right now it is working, But it might fail sometime when the webpage has other images as well that are not relevant for you.
In that case you need to figure out how you would particularly select those images using some HTML structural data.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.