Download the PDF from arxiv.
(arxiv_id: str, output_path: Path)
| 120 | |
| 121 | |
| 122 | def download_pdf(arxiv_id: str, output_path: Path) -> bool: |
| 123 | """Download the PDF from arxiv.""" |
| 124 | pdf_url = f"https://arxiv.org/pdf/{arxiv_id}.pdf" |
| 125 | print(f"Downloading PDF from {pdf_url}...") |
| 126 | |
| 127 | try: |
| 128 | resp = requests.get(pdf_url, timeout=60, stream=True) |
| 129 | resp.raise_for_status() |
| 130 | |
| 131 | with open(output_path, "wb") as f: |
| 132 | for chunk in resp.iter_content(chunk_size=8192): |
| 133 | f.write(chunk) |
| 134 | |
| 135 | file_size = output_path.stat().st_size |
| 136 | print(f" Downloaded: {file_size / 1024:.0f} KB") |
| 137 | return True |
| 138 | |
| 139 | except requests.RequestException as e: |
| 140 | print(f" FAILED: {e}", file=sys.stderr) |
| 141 | return False |
| 142 | |
| 143 | |
| 144 | def extract_with_pymupdf4llm(pdf_path: Path) -> str | None: |