sec-edgar-downloader icon indicating copy to clipboard operation
sec-edgar-downloader copied to clipboard

Download straight to variable / memory

Open Elijas opened this issue 1 year ago • 1 comments

Hello 👋,

I'm using sec-edgar-downloader and would like to know if it's possible to directly download filings (e.g., 10-Q for AAPL) in HTML format without file access?

The workaround I'm using currently is:

from sec_downloader import Downloader

dl = Downloader("MyCompanyName", "[email protected]")
html = dl.get_latest_html("10-Q", "AAPL")
print(f"{html[:50]}...")
<?xml version="1.0" ?><!--XBRL Document Created wi...

which is implemented as

# pip install sec-edgar-downloader sec-downloader

from sec_edgar_downloader import Downloader
from sec_downloader import DownloadStorage

ONLY_HTML = "**/*.htm*"

storage = DownloadStorage(filter_pattern=ONLY_HTML)
with storage as path:
    dl = Downloader("MyCompanyName", "[email protected]", path)
    dl.get("10-Q", "AAPL", limit=1, download_details=True)
# all files are now deleted and only stored in memory

content = storage.get_file_contents()[0].content
print(f"{content[:50]}...")
<?xml version="1.0" ?><!--XBRL Document Created wi...

Elijas avatar Oct 12 '23 03:10 Elijas

Hi @Elijas, currently this tool only downloads and stores filings onto disk, but I will note this down for a future improvement.

jadchaar avatar Oct 29 '23 05:10 jadchaar