This commit is contained in:
√(noham)² committed 2025-04-14 00:46:41 +02:00
1 parent 1135b4ddac
commit 85b53eda9d
57 files changed
+138 -23

No files matched your search

Executable
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
# Configuration
DUMP_DIR="dump"
OUTPUT_DIR="output"
TEX_CMD="pdflatex"
# Create output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"
# Check if dump directory exists
if [ ! -d "$DUMP_DIR" ]; then
echo "Error: $DUMP_DIR directory does not exist"
exit 1
fi
# Process all .tex files in the dump directory
echo "Processing .tex files from $DUMP_DIR..."
for tex_file in "$DUMP_DIR"/*.tex; do
# Check if there are any .tex files
if [ ! -f "$tex_file" ]; then
echo "No .tex files found in $DUMP_DIR"
exit 0
fi
filename=$(basename "$tex_file")
echo "Processing $filename..."
# Run pdflatex
$TEX_CMD -output-directory="$OUTPUT_DIR" "$tex_file"
# Check if successful
if [ $? -eq 0 ]; then
echo "Successfully generated PDF for $filename"
else
echo "Error generating PDF for $filename"
fi
done
echo "All processing complete. Output files are in $OUTPUT_DIR"
+45 -23
View File
@@ -29,6 +29,10 @@ class Part:
class Chapitre: class Chapitre:
def __init__(self, title, url=None): def __init__(self, title, url=None):
if ':' in title:
title = title.split(':')[1].strip()
title = title.lower()
title = title[0].upper() + title[1:] if title else ""
self.title = title self.title = title
self.parts = [] self.parts = []
self.url = url self.url = url
@@ -124,7 +128,26 @@ class LatexFile:
self.add_footer() self.add_footer()
self.save() self.save()
def fetch_chapitre(quoi): def parse(content):
soup2 = BeautifulSoup(str(content), 'lxml')
for tag in soup2.find_all(['span', 'a', 'img']):
tag.extract()
questions = []
ol_list = soup2.find('ol', class_='enumeratechiffre')
if ol_list:
for i, li in enumerate(ol_list.find_all('li'), 1):
if i == 1:
# Add a line break before the first question
questions.append("\\par")
questions.append(f"{i}. {li.get_text().strip()}")
list_text = "\n\n".join(questions)
ol_list.replace_with(list_text)
content = soup2.get_text().strip()
return content
def fetch_chapitre(page):
headers = { headers = {
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
'accept-language': 'fr-FR,fr;q=0.7', 'accept-language': 'fr-FR,fr;q=0.7',
@@ -142,12 +165,7 @@ def fetch_chapitre(quoi):
'upgrade-insecure-requests': '1', 'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
} }
params = { response = requests.get(page, headers=headers)
'action': 'affiche',
'quoi': quoi,
'type': 'fexo',
}
response = requests.get('https://bibmath.net/ressources/index.php', headers=headers, params=params)
if response.status_code == 200: if response.status_code == 200:
soup = BeautifulSoup(response.text, 'lxml') soup = BeautifulSoup(response.text, 'lxml')
article = soup.find('article', id='contenugauche') article = soup.find('article', id='contenugauche')
@@ -175,20 +193,16 @@ def fetch_chapitre(quoi):
stars_count = len(exo_title_div.find_all('img')) stars_count = len(exo_title_div.find_all('img'))
enonce = element.find('div', class_='enonce').find('div', class_='inner').get_text(strip=True) enonce = element.find('div', class_='enonce').find('div', class_='inner')
if ".Existe-t" in enonce: enonce = parse(enonce)
print(element)
indication_div = element.find('div', class_='indication') indication_div = element.find('div', class_='indication')
indication = ( indication = indication_div.find('div', class_='inner')
indication_div.find('div', class_='inner').get_text(strip=True) indication = parse(indication)
if indication_div else "No indication"
)
answer_div = element.find('div', class_='corrige') answer_div = element.find('div', class_='corrige')
answer = ( answer = answer_div.find('div', class_='inner')
answer_div.find('div', class_='inner').get_text(strip=True) answer = parse(answer)
if answer_div else "No answer"
)
exercise = Exercise( exercise = Exercise(
number=exercise_number, number=exercise_number,
@@ -207,9 +221,17 @@ def fetch_chapitre(quoi):
else: else:
print(f"Request failed with status code: {response.status_code}") print(f"Request failed with status code: {response.status_code}")
quoi = 'mpsi/feuillesexo/matrices' def get_page(page):
chapitre = fetch_chapitre(quoi) chapitre = fetch_chapitre(page)
title = chapitre.title
latex_file = LatexFile(f'dump/{title}.tex')
latex_file.generate_latex(chapitre)
print(f"LaTeX file generated: dump/{title}.tex")
latex_file = LatexFile('file.tex') if __name__ == "__main__":
latex_file.generate_latex(chapitre) # page = "https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/prehilbert&type=fexo"
print("LaTeX file generated: file.tex") # get_page(page)
with open('pages.txt', 'r') as f:
for line in f:
page = line.strip()
get_page(page)
+19
View File
@@ -0,0 +1,19 @@
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/groupe&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/anneau&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/alglin&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/reduction&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/polynomeendomorphisme&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/endoeuclidien&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/evn&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/topoevn&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/complementstopo&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/vectorielle&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/integralesimpropres&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/foncdefintegrales&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/serie&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/suiserfonc&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/serieent&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/equadiffs&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/calculdiff&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/espacesproba&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mathspe/feuillesexo/vadiscrete&type=fexo
+34
View File
@@ -0,0 +1,34 @@
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/logique&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/ensembleapplicationrelation&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/calculalgebrique&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/systemeslineaires&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/inegalites&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/trigo&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/complexes&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/foncusu&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/primitives&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/equadiffs&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/reels&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/suites&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/limitecontinuite&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/derivee&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/convexe&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/arithmetique&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/matrices&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/groupeanneaucorps&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/polynomes&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/fracrat&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/compafonctions&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/dls&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/integration&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/series&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/famillessommables&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/ev&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/dimfinie&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/al&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/matricesal&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/determinant&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/prehilbert&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/denombrement&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/espaceproba&type=fexo
https://bibmath.net/ressources/index.php?action=affiche&quoi=mpsi/feuillesexo/va&type=fexo
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.