-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
24 lines (21 loc) · 781 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from bs4 import BeautifulSoup
import csv
output = open("output.csv", "w", newline="")
writer = csv.writer(output)
writer.writerow(['name','designation','@image'])
with open("cs_mbcet.html", "r", encoding='utf8') as html_file:
content = html_file.read()
soup = BeautifulSoup(content, "lxml")
tags = soup.find_all(class_ = "faculty-item")
i = 0
for tag in tags:
i = i + 1
name = tag.div.h3.a.text
name = ' '.join(name.split())
designation = tag.p.text
designation = ' '.join(designation.split())
image = "F:/Downloads/files/" +str(tag.img['src']).split("/")[-1]
writer.writerow([name, designation, image])
# print(name + " working as " + designation + ", image: " + image)
output.close()
print(i)