Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
events-wrangler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VALLET Nathan
events-wrangler
Commits
96eb4942
Commit
96eb4942
authored
1 year ago
by
VALLET Nathan
Browse files
Options
Downloads
Patches
Plain Diff
add preview of html page generation
parent
a97bb08f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
aggreg.py
+29
-1
29 additions, 1 deletion
aggreg.py
with
29 additions
and
1 deletion
aggreg.py
+
29
−
1
View file @
96eb4942
import
feedparser
from
urllib.parse
import
urlparse
from
datetime
import
datetime
import
time
def
charge_urls
(
liste_url
:
list
[
str
])
->
list
[
dict
[
str
,
any
]
|
None
]:
# if the key 'bozo' is true, then the feed had an error during processing, so we set it to None
...
...
@@ -31,7 +33,33 @@ def fusion_flux(liste_url: list[str], liste_flux: list[dict[str, any] | None],
return
feeds
def
genere_html
(
liste_evenements
:
list
[
dict
[
str
,
str
]],
chemin_html
:
str
)
->
None
:
output
=
"
<!DOCTYPE html><html lang=
\"
en
\"
><head><meta charset=
\"
utf-8
\"
><meta name=
\"
viewport
\"
content=
\"
width=device-width, initial-scale=1
\"
><title>Events log</title><link rel=
\"
stylesheet
\"
href=
\"
css/feed.css
\"
type=
\"
text/css
\"
/></head><body><article><header><h1>Events log</h1></header>
"
output
+=
f
"
<p>
{
time
.
asctime
()
}
</p>
"
for
evenement
in
liste_evenements
:
output
+=
"
<article><header>
"
output
+=
f
"
<h2>
{
evenement
[
'
titre
'
]
}
</h2>
"
output
+=
"
</header>
"
output
+=
f
"
<p>from:
{
evenement
[
'
serveur
'
]
}
</p>
"
output
+=
f
"
<p>
{
evenement
[
'
date_publi
'
]
}
</p>
"
output
+=
f
"
<p>
{
evenement
[
'
categorie
'
]
}
</p>
"
output
+=
f
"
<p>
{
evenement
[
'
guid
'
]
}
</p>
"
output
+=
f
"
<p><a href=
\"
{
evenement
[
'
lien
'
]
}
\"
>
{
evenement
[
'
lien
'
]
}
</a></p>
"
output
+=
f
"
<p>
{
evenement
[
'
description
'
]
}
</p>
"
output
+=
"
</article>
"
output
+=
"
</article></body></html>
"
with
open
(
chemin_html
,
"
w
"
)
as
outputfile
:
outputfile
.
write
(
output
)
def
main
():
raise
NotImplementedError
urls
=
[
f
"
http://192.168.78.
{
i
}
/rss.xml
"
for
i
in
range
(
3
,
15
)]
charge
=
charge_urls
(
urls
)
evenements
=
fusion_flux
(
urls
,
charge
,
None
)
print
(
evenements
)
genere_html
(
evenements
,
"
aggreg.html
"
)
if
__name__
==
"
__main__
"
:
main
()
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