i dont know why but it is not taking data from html page?
I m not able to get data from html page
Hi,
If you do exactly what is taught in the videos, you would definitely get the results.
If you are getting error, share your code on https://ide.codingblocks.com, and also attach a screenshot of the error on what line it is throwing you an error. It would be much easier to resolve by looking at the error.
Thanks
why i am getting nothing in ans ?
Also i tried the same way on inspirational quotes but there also it not worked why?
code:->
import bs4
import requests
url=“https://www.passiton.com/inspirational-quotes?page=4”
response=requests.get(url)
response.content
soup = bs4.BeautifulSoup(response.content, “html.parser” )
article_element=soup.findAll(“img alt”)
###################### when i m using “img” it is giving output but when i use
“img alt” it didnt why?
article_element
Hey,
in the screenshot, you’re trying to find an element called id which is not present in the webpage. That’s why it results in an empty list.
In the code you posted here when you put findAll("img alt")
it means you are trying to find an element img alt which is also not present.
Only img element is present in the webpage. So, using only img gives you some results.
If you want to select elements with some attributes use this:
article_element=soup.findAll(“img”, attrs={“class” : “shadow”})
Now this will give you all the imgs having class as shadow, so you will get 32 images that are the qoutes.
I also request you to make use of ide.codingblocks.com for sharing codes.
can u tell me how does your ide works ,like i need to just save my code there?
If you are familiar with HTML syntax, here img is a tag, while alt is an attribute. This alt will be different for all the images. In findAll function we provide a tag not attributes. One attribute you can see it has a class and it’s value shadow
is common to all the images. That’s why, the line of code i gave you means, get all the img elements where class attribute is shadow.
For online ide, just open the ide link, and you can choose the desired lang - python, copy paste you code there, there is a button on top save code. save the code, and share the link generate or URL… URL for different codes will be different.