elm.web.utilities.write_url_doc_to_file

write_url_doc_to_file(doc, file_content, out_dir, make_name_unique=False)[source]

Write a file pulled from URL to disk.

Parameters:
  • doc (elm.web.document.Document) – Document containing meta information about the file. Must have a “source” key in the metadata dict containing the URL, which will be converted to a file name using compute_fn_from_url().

  • file_content (str | bytes) – File content, typically string text for HTML files and bytes for PDF file.

  • out_dir (path-like) – Path to directory where file should be stored.

  • make_name_unique (bool, optional) – Option to make file name unique by adding a UUID at the end of the file name. By default, False.

Returns:

Path – Path to output file.