Answers for "beautifulsoup find by id"

1

using bs4 to obtain html element by id

>>> import BeautifulSoup
>>> soup = BeautifulSoup.BeautifulSoup('<html><body><div id="articlebody"> ... </div></body></html')
>>> soup.find("div", {"id": "articlebody"})
<div id="articlebody"> ... </div>
Posted by: Guest on November-27-2020
0

beautifulsoup find_all by id

from BeautifulSoup import BeautifulSoup 
f = open('/Users/myUserName/Desktop/contacts.html')
soup = BeautifulSoup(f) 
list = soup.findAll('div', attrs={'class':'fcontent'})
print len(list)
Posted by: Guest on June-10-2021

Code answers related to "beautifulsoup find by id"

Python Answers by Framework

Browse Popular Code Answers by Language