Asked 4 years ago
11 Aug 2020
Views 2131
steave ray

steave ray posted

how to extract a content of div by ID in Beautiful Soup

 
from bs4 import BeautifulSoup
...
                   
soup.find("div", { "id" : "data" })


it should return html / value of the that div id with data
but it return nothing

so i am not using correct code or what.

how to extract the text from the html by id of div .
david

david
answered Nov 30 '-1 00:00


from bs4 import BeautifulSoup
soup = BeautifulSoup('html goes here', 'html.parser')
service = soup.find('div', id='myid')


you can use find , find_all by id as per above
Post Answer