Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mason-today-web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
mason-today-web
Commits
bb610e31
Commit
bb610e31
authored
Dec 07, 2017
by
Landon DeCoito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completed 'cleanup' function for squashing The Character and slightly revised README
parent
3bb91ef1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
25 deletions
+26
-25
README.md
README.md
+2
-0
pscripts/parscript.py
pscripts/parscript.py
+24
-25
No files found.
README.md
View file @
bb610e31
...
...
@@ -3,3 +3,5 @@ Mason Today Web is a shitty version of the Mason Today project. It will be the c
Please refer to the requirements.txt for information on what packages to install to properly run the program.
We make soup. A lot of it.
This is currently licensed under the "wut" license. Plznosteal
pscripts/parscript.py
View file @
bb610e31
print
"and we begin"
from
bs4
import
BeautifulSoup
import
requests
class
Event
:
def
__init__
(
self
,
entryTag
):
#where var entry
Soup
is a specific event tag
def
__init__
(
self
,
entryTag
):
#where var entry
Tag
is a specific event tag
self
.
__name
=
entryTag
.
find
(
'title'
).
string
self
.
__description
=
entryTag
.
find
(
'content'
).
string
self
.
__time
=
"timeplaceholder"
...
...
@@ -11,35 +14,31 @@ class Event:
def
__str__
(
self
):
return
self
.
__name
+
": "
+
self
.
__description
+
"
\n\n
"
def
cleanup
(
string
):
ctr
=
0
while
ctr
<
len
(
string
):
def
cleanup
(
str
):
str
=
str
.
replace
(
"&"
,
"&"
)
str
=
str
.
replace
(
" "
,
" "
)
str
=
str
.
replace
(
"–"
,
"-"
)
str
=
str
.
replace
(
"<"
,
"<"
)
str
=
str
.
replace
(
">"
,
">"
)
str
=
str
.
replace
(
"<br/>"
,
"
\n
"
)
return
str
from
bs4
import
BeautifulSoup
import
requests
f
=
requests
.
get
(
"http://25livepub.collegenet.com/calendars/events_all.xml"
)
#grabs the xml from 25live
#f = open("events.xml", "r") #Opens a local document. events.xml is a shortened version of the larger events doc
soup
=
BeautifulSoup
(
f
.
text
,
"lxml"
)
#creates soup of the xml
xmldoc
=
requests
.
get
(
"http://25livepub.collegenet.com/calendars/events_all.xml"
)
#grabs the xml from 25live
#xmldoc = open("events.xml", "r") #Opens a local document. events.xml is a shortened version of the larger events doc
entries
=
soup
.
find_all
(
'entry'
)
#creates a list of all the entry tags from the xml
print
type
(
entries
[
0
]),
"
\n
"
#prints the first entry
print
entries
[
0
].
prettify
(),
"
\n
"
#prints the first entry out
print
entries
[
0
].
find
(
'content'
).
prettify
(),
"
\n
"
#prints the first content tag in the first entry
xmldoc
=
cleanup
(
xmldoc
.
text
)
print
xmldoc
soup
=
BeautifulSoup
(
xmldoc
,
"lxml"
)
#creates soup of the xml
print
soup
.
prettify
(),
"
\n\n
"
titles
=
[]
for
item
in
entries
:
titles
.
append
(
item
.
find
(
'title'
).
string
)
#this iterates through the entries and puts each event's title into a list
print
titles
,
"
\n
"
entries
=
soup
.
find_all
(
'entry'
)
#creates a list of all the entry tags from the xml
#print type(entries[0]), "\n" #prints the first entry
#print entries[0].prettify(), "\n" #prints the first entry out
#print entries[0].find('content').prettify(), "\n" #prints the first content tag in the first entry
events
=
[]
for
item
in
entries
:
events
.
append
(
Event
(
item
))
print
events
#for item in entries:
# print item.find('content').string, "\n\n"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment