pdfdol.download#
Download PDF articles from markdown-formatted text.
Extracts [title](url) links from markdown and downloads the PDFs,
with validation (Content-Type check + %PDF magic byte check).
Main entry points:
>>> download_articles(md_string, save_dir='~/Downloads')
>>> download_articles_by_section(md_string, rootdir='~/Downloads')
Functions
|
Download articles from markdown-formatted text and save them as PDFs. |
|
Download articles organized by markdown sections into subdirectories. |
- pdfdol.download.download_articles(md_string, save_dir='/home/runner/Downloads', *, save_non_pdf=False, verbose=True)[source]#
Download articles from markdown-formatted text and save them as PDFs.
Extracts links matching
- **[title](url)**and downloads the URL. Only saves files whose Content-Type isapplication/pdfand whose first bytes are%PDF.- Parameters:
- Returns:
list – URLs that failed to download or were not valid PDFs.
Tips
—-
When your knowledge base has many files, consider aggregating them
into a single PDF with
pdfdol.concat_pdfs.
- pdfdol.download.download_articles_by_section(md_string, rootdir=None, save_non_pdf=False, *, section_marker='###')[source]#
Download articles organized by markdown sections into subdirectories.
Parses sections delimited by
section_marker(default###) and creates a subdirectory for each section, then downloads articles within each section usingdownload_articles().- Parameters:
- Returns:
Section names as keys, lists of failed URLs as values.
- Return type: