from urllib.request importurlopenfrom bs4 importBeautifulSoup
html_doc= """
The Dormouse's storyThe Dormouse's story
Once upon a time there were three little sisters; and their names were
Lacie and
and they lived at the bottom of a well.
...
...
...
"""soup= BeautifulSoup(html_doc, "html.parser")
link3= soup.find(id='link3')#Tillie
print(link3)#
print(type(link3))#{'href': 'http://example.com/tillie', 'title': 'this is title!', 'id': 'link3', 'class': ['sister', 'text-bold', 'text-danger']}
print(link3.attrs)#Tillie
print(link3.get_text())#this is title!
print(link3["title"])
all_a= soup.find_all('a')#Elsie
print(all_a[0])#['Elsie', 'Lacie', 'Tillie']
print(soup.find_all(text=["Tillie", "Elsie", "Lacie"]))#[
...
]print(soup.find_all("p", {"class":"red", "class":"red green"}))