I want to extract a div using its style property padding-left: 16px
, something like shown in the following Python code. But apparently it doesn't work. I know how to extract an element using its class, id or tags. Is there a way to do the same using style property?
from bs4 import BeautifulSoup
f = open("C:\Users\admin\Documents\GitHub\RedditCrawler\new.html");
soup = BeautifulSoup(f);
f.close();
hr2 = soup.find('div', style={"padding-left":"16px"});
print(hr2);
Following is the div I'm trying to extract from my html file:
<html>
<div style="padding-left:16px;">This is the deal</div>
</html>