I'am new in Python and I run in a problem. There is a website where that site has a complete structure. I know how can I find a div, or other tag, but when I found that tag (eg. with class name), I would like to gathering all parameters with value, but I can't. So, My question is how can I gathering a random tag's all parameters and values after I found that?
-------------------------------------------------------------------------------------------------------------------------
Best Answer;
How I found:
from bs4 import BeautifulSoup as BS
.
.
.
soup = BS(page.content, 'html.parser')
soup.prettify()
div = soup.find('div', {'class':'abc'})
-------------------------------------------------------------------------------------------------------------------------
Best Answer;
If you want to get all the element's attributes, simply use the
.attrs
property:print(div.attrs)
This would print out a dictionary where keys are attribute names and values are attribute values.
No comments:
Post a Comment