forked from shuijian7/SlackTrack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtacourses.py
More file actions
35 lines (24 loc) · 754 Bytes
/
tacourses.py
File metadata and controls
35 lines (24 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
my_url = 'http://catalog.uoregon.edu/arts_sciences/theaterarts/#courseinventory'
#opening up conneciton, grabbing the page
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")
data = []
#grabs containers
containers = page_soup.findAll("div",{"class":"courseblock"})
filename = "tacourses.txt"
f = open(filename, "w")
for container in containers:
final = container.p.text
final.split(" ")
data.append(final)
line = str(data)
###f.write(line)
#for i in range len of containers and then data [i]
#f.write(data) # + "\n")
for item in data:
f.write("%s\n" % item)
print(data)