mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
add: daily quote
This commit is contained in:
parent
e53acf2106
commit
a5fc096858
3 changed files with 29 additions and 1 deletions
25
.local/bin/citation.py
Executable file
25
.local/bin/citation.py
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
import random
|
||||
from colorama import Fore, Style
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
URL = "https://www.mon-poeme.fr/citation-du-jour/"
|
||||
|
||||
response = requests.get(URL)
|
||||
content = response.content
|
||||
soup = BeautifulSoup(content, "html.parser")
|
||||
|
||||
blockquote = soup.find_all('blockquote')
|
||||
figcaption = soup.find_all('figcaption')
|
||||
|
||||
cs = zip(
|
||||
map(lambda x: x.p.span.text, blockquote),
|
||||
map(lambda x: (x.span.a.text, x.span.cite.text), figcaption),
|
||||
)
|
||||
|
||||
c = random.choice(list(cs))
|
||||
|
||||
print(f"{Style.BRIGHT}{c[0]}{Style.RESET_ALL}")
|
||||
print(f"{Style.DIM}~ {c[1][0]} « {c[1][1]} »{Style.RESET_ALL}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue