Interpret a web page as a PDF document >>> from doctr.io import DocumentFile >>> doc = DocumentFile.from_url("https://www.yoursite.com") Args: url: the URL of the target web page **kwargs: additional parameters to :meth:`pypdfium2.PdfPage.render`
(cls, url: str, **kwargs)
| 39 | |
| 40 | @classmethod |
| 41 | def from_url(cls, url: str, **kwargs) -> list[np.ndarray]: |
| 42 | """Interpret a web page as a PDF document |
| 43 | |
| 44 | >>> from doctr.io import DocumentFile |
| 45 | >>> doc = DocumentFile.from_url("https://www.yoursite.com") |
| 46 | |
| 47 | Args: |
| 48 | url: the URL of the target web page |
| 49 | **kwargs: additional parameters to :meth:`pypdfium2.PdfPage.render` |
| 50 | |
| 51 | Returns: |
| 52 | the list of pages decoded as numpy ndarray of shape H x W x 3 |
| 53 | """ |
| 54 | requires_package( |
| 55 | "weasyprint", |
| 56 | "`.from_url` requires weasyprint installed.\n" |
| 57 | + "Installation instructions: https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#installation", |
| 58 | ) |
| 59 | pdf_stream = read_html(url) |
| 60 | return cls.from_pdf(pdf_stream, **kwargs) |
| 61 | |
| 62 | @classmethod |
| 63 | def from_images(cls, files: Sequence[AbstractFile] | AbstractFile, **kwargs) -> list[np.ndarray]: |