Skip to content

Commit aed28de

Browse files
authored
Add files via upload
1 parent bc8e290 commit aed28de

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Web Scraping/day_45.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from bs4 import BeautifulSoup
2+
# import lxml
3+
4+
with open("website.html", encoding="utf8") as file:
5+
contents = file.read()
6+
7+
soup = BeautifulSoup(contents, "html.parser")
8+
# print(soup.title.string)
9+
# print(soup.prettify())
10+
# print(soup.li)
11+
all_tags = soup.find_all(name="a")
12+
# print(all_tags)
13+
14+
for tag in all_tags:
15+
# print(tag.getText())
16+
# print(tag.get("href"))
17+
pass
18+
19+
heading = soup.find(name="h1", id="name")
20+
# print(heading)
21+
head1 = soup.find(name="h3", class_="heading")
22+
# print(head1)
23+
24+
select = soup.select_one(selector="p a")
25+
select1 = soup.select_one(selector="#name")
26+
# print(select1)
27+
28+
headings = soup.select(".heading")
29+
print(heading)

0 commit comments

Comments
 (0)