Datasets:
Guillaume Raille
commited on
ruff format and sort
Browse files
main.py
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
|
|
|
|
|
| 1 |
import httpx
|
| 2 |
|
|
|
|
|
|
|
| 3 |
RAW_PDF_URLS = [
|
| 4 |
"https://www.ebooksgratuits.com/ebooksfrance/moliere-oeuvres_completes_1.pdf",
|
| 5 |
"https://www.ebooksgratuits.com/ebooksfrance/moliere-oeuvres_completes_2.pdf",
|
| 6 |
]
|
| 7 |
|
|
|
|
| 8 |
def download_pdf(url: str, output_path: str) -> None:
|
| 9 |
"""Download a PDF from the given URL and save it to the specified output path."""
|
| 10 |
with httpx.stream("GET", url, follow_redirects=True) as response:
|
|
@@ -13,6 +18,7 @@ def download_pdf(url: str, output_path: str) -> None:
|
|
| 13 |
for chunk in response.iter_bytes():
|
| 14 |
f.write(chunk)
|
| 15 |
|
|
|
|
| 16 |
def main():
|
| 17 |
# 1. fetch raw data if (not already fetched)
|
| 18 |
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
|
| 3 |
import httpx
|
| 4 |
|
| 5 |
+
DATA_DIR = Path.cwd() / "data"
|
| 6 |
+
|
| 7 |
RAW_PDF_URLS = [
|
| 8 |
"https://www.ebooksgratuits.com/ebooksfrance/moliere-oeuvres_completes_1.pdf",
|
| 9 |
"https://www.ebooksgratuits.com/ebooksfrance/moliere-oeuvres_completes_2.pdf",
|
| 10 |
]
|
| 11 |
|
| 12 |
+
|
| 13 |
def download_pdf(url: str, output_path: str) -> None:
|
| 14 |
"""Download a PDF from the given URL and save it to the specified output path."""
|
| 15 |
with httpx.stream("GET", url, follow_redirects=True) as response:
|
|
|
|
| 18 |
for chunk in response.iter_bytes():
|
| 19 |
f.write(chunk)
|
| 20 |
|
| 21 |
+
|
| 22 |
def main():
|
| 23 |
# 1. fetch raw data if (not already fetched)
|
| 24 |
|