Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Armory Dashboard
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anton Sarukhanov
Armory Dashboard
Commits
c2893bea
Commit
c2893bea
authored
7 years ago
by
Anton Sarukhanov
Browse files
Options
Downloads
Patches
Plain Diff
Make protocol prefix and trailing slash optional. Add refresh, extra Escrime URLs, optgroups.
parent
03b49128
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
scrape.py
+10
-4
10 additions, 4 deletions
scrape.py
templates/base.html
+2
-1
2 additions, 1 deletion
templates/base.html
templates/index.html
+18
-4
18 additions, 4 deletions
templates/index.html
templates/live.html
+3
-0
3 additions, 0 deletions
templates/live.html
with
33 additions
and
9 deletions
scrape.py
+
10
−
4
View file @
c2893bea
...
@@ -6,7 +6,10 @@ from itertools import repeat
...
@@ -6,7 +6,10 @@ from itertools import repeat
def
scrape
(
results_url
):
def
scrape
(
results_url
):
results
=
requests
.
get
(
results_url
)
try
:
results
=
requests
.
get
(
results_url
)
except
requests
.
exceptions
.
MissingSchema
:
results
=
requests
.
get
(
"
http://{}
"
.
format
(
results_url
))
results_tree
=
html
.
fromstring
(
results
.
content
)
results_tree
=
html
.
fromstring
(
results
.
content
)
try
:
try
:
event_urls
=
results_tree
.
xpath
(
event_urls
=
results_tree
.
xpath
(
...
@@ -20,13 +23,16 @@ def scrape(results_url):
...
@@ -20,13 +23,16 @@ def scrape(results_url):
events
=
[]
events
=
[]
for
event_url
in
event_urls
:
for
event_url
in
event_urls
:
if
not
urlparse
(
event_url
).
netloc
:
if
not
urlparse
(
event_url
).
netloc
:
event_url
=
urljoin
(
results
_
url
,
event_url
)
event_url
=
urljoin
(
results
.
url
,
event_url
)
event
=
requests
.
get
(
event_url
)
event
=
requests
.
get
(
event_url
)
event_tree
=
html
.
fromstring
(
event
.
content
)
event_tree
=
html
.
fromstring
(
event
.
content
)
event_details
=
event_tree
.
xpath
(
event_details
=
event_tree
.
xpath
(
'
//span[@class=
"
tournDetails
"
]/text()
'
)
'
//span[@class=
"
tournDetails
"
]/text()
'
)
event_name
=
event_details
[
0
]
try
:
event_time
=
event_details
[
1
]
event_name
=
event_details
[
0
]
event_time
=
event_details
[
1
]
except
:
raise
(
Exception
(
"
Failed to interpret live results for event
\"
{}
\"
.
"
.
format
(
event_url
)))
if
event_tree
.
xpath
(
'
//a[text()=
"
Final Results
"
]
'
):
if
event_tree
.
xpath
(
'
//a[text()=
"
Final Results
"
]
'
):
fencers
=
event_tree
.
xpath
(
'
//div[@id=
"
finalResults
"
]/table/tr/td[2]/text()
'
)
fencers
=
event_tree
.
xpath
(
'
//div[@id=
"
finalResults
"
]/table/tr/td[2]/text()
'
)
fencers
=
dict
(
zip
(
fencers
,
repeat
(
"
Checked In
"
)))
fencers
=
dict
(
zip
(
fencers
,
repeat
(
"
Checked In
"
)))
...
...
This diff is collapsed.
Click to expand it.
templates/base.html
+
2
−
1
View file @
c2893bea
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<head>
<head>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<title>
Armory Dashboard
</title>
<title>
Armory Dashboard
</title>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1, user-scal
e
able=0"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"
>
<link
rel=
"stylesheet"
href=
"{{ url_for('static', filename='css/style.css') }}?t=20180325"
>
<link
rel=
"stylesheet"
href=
"{{ url_for('static', filename='css/style.css') }}?t=20180325"
>
<link
rel=
"apple-touch-icon"
sizes=
"180x180"
href=
"{{ url_for('static', filename='images/icons/apple-touch-icon.png') }}?t=20180325"
>
<link
rel=
"apple-touch-icon"
sizes=
"180x180"
href=
"{{ url_for('static', filename='images/icons/apple-touch-icon.png') }}?t=20180325"
>
<link
rel=
"icon"
type=
"image/png"
sizes=
"32x32"
href=
"{{ url_for('static', filename='images/icons/favicon-32x32.png') }}?t=20180325"
>
<link
rel=
"icon"
type=
"image/png"
sizes=
"32x32"
href=
"{{ url_for('static', filename='images/icons/favicon-32x32.png') }}?t=20180325"
>
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
<meta
name=
"msapplication-TileColor"
content=
"#da532c"
>
<meta
name=
"msapplication-TileColor"
content=
"#da532c"
>
<meta
name=
"msapplication-config"
content=
"{{ url_for('static', filename='images/icons/browserconfig.xml') }}?t=20180325"
>
<meta
name=
"msapplication-config"
content=
"{{ url_for('static', filename='images/icons/browserconfig.xml') }}?t=20180325"
>
<meta
name=
"theme-color"
content=
"#ffffff"
>
<meta
name=
"theme-color"
content=
"#ffffff"
>
{% block extra_head %}{% endblock extra_head %}
</head>
</head>
<body
class=
"page-{{ request.endpoint }}"
>
<body
class=
"page-{{ request.endpoint }}"
>
{% block content %}{% endblock content %}
{% block content %}{% endblock content %}
...
...
This diff is collapsed.
Click to expand it.
templates/index.html
+
18
−
4
View file @
c2893bea
...
@@ -12,9 +12,23 @@
...
@@ -12,9 +12,23 @@
<label>
Live Results URL:
<label>
Live Results URL:
<select
name=
"results_url"
>
<select
name=
"results_url"
>
<option
value=
""
selected
disabled
>
-- Select One --
</option>
<option
value=
""
selected
disabled
>
-- Select One --
</option>
<option
value=
"http://escrimeresults.com/cobra/"
>
Cobra
</option>
<optgroup
label=
"Escrime Management"
>
<option
value=
"http://escrimeresults.com/thrust/"
>
Thrust
</option>
<option
value=
"http://escrimeresults.com/tournaments/NCAA.html"
>
NCAA
</option>
<option
value=
"http://njfencingresults.org/liveresults/"
>
NJFencingResults.org
</option>
<option
value=
"http://escrimeresults.com/tournaments/Atlantic-Coast-Conference.html"
>
Atlantic Coast Conference
</option>
<option
value=
"http://escrimeresults.com/tournaments/Ivy-League.html"
>
Ivy League
</option>
<option
value=
"http://escrimeresults.com/cobra/"
>
Cobra
</option>
<option
value=
"http://escrimeresults.com/thrust/"
>
Thrust
</option>
<option
value=
"http://escrimeresults.com/tournaments/NJSIAA.html"
>
NJSIAA
</option>
<option
value=
"http://escrimeresults.com/Candlewood/"
>
Candlewood
</option>
<option
value=
"http://escrimeresults.com/tournaments/U-Penn.html"
>
U Penn
</option>
<option
value=
"http://escrimeresults.com/tournaments/Temple-University.html"
>
Temple U
</option>
<option
value=
"http://escrimeresults.com/Big1/"
>
Big1
</option>
<option
value=
"http://escrimeresults.com/tournaments/US-Collegiate-Squad-Championships.html"
>
US Collegiate Squad
</option>
<option
value=
"http://escrimeresults.com/MKHS/"
>
MKHS
</option>
</optgroup>
<optgroup
label=
"NJ Division"
>
<option
value=
"http://njfencingresults.org/liveresults/"
>
NJFencingResults.org/liveresults
</option>
</optgroup>
</select>
</select>
</label>
</label>
<input
type=
"submit"
value=
"Go!"
>
<input
type=
"submit"
value=
"Go!"
>
...
@@ -23,7 +37,7 @@
...
@@ -23,7 +37,7 @@
<p>
<p>
<form
action=
"{{ url_for('live') }}"
method=
"get"
>
<form
action=
"{{ url_for('live') }}"
method=
"get"
>
<label>
Other URL:
<label>
Other URL:
<input
name=
"results_url"
placeholder=
"
http://
example.com/liveresults"
>
<input
name=
"results_url"
placeholder=
"example.com/liveresults"
>
</label>
</label>
<input
type=
"submit"
value=
"Go!"
>
<input
type=
"submit"
value=
"Go!"
>
</form>
</form>
...
...
This diff is collapsed.
Click to expand it.
templates/live.html
+
3
−
0
View file @
c2893bea
{% extends "base.html" %}
{% extends "base.html" %}
{% block extra_head %}
<meta
http-equiv=
"refresh"
content=
"60; URL={{ url_for('live') }}"
>
{% endblock extra_head %}
{% block content %}
{% block content %}
<header>
<header>
<span
class=
"back-to-home"
><a
href=
"{{ url_for('index') }}"
>
Back to Home
</a></span>
<span
class=
"back-to-home"
><a
href=
"{{ url_for('index') }}"
>
Back to Home
</a></span>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment