Skip to content

Commit

Permalink
Updated function names to be PEP; added functionality to get differen…
Browse files Browse the repository at this point in the history
…t types of documents
  • Loading branch information
joeyism committed Oct 26, 2019
1 parent 865a05a commit 94bae45
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion edgar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .txtml import TXTML
from .company import Company

__version__ = "2.0.4"
__version__ = "3.0.0"

modules = glob.glob(dirname(__file__)+"/*.py")
__all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')]
16 changes: 16 additions & 0 deletions edgar/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ def get_all_filings(self, filing_type="", prior_to="", ownership="include", no_o
page = requests.get(url)
return html.fromstring(page.content)

def get_document_type_from_10K(self, document_type, no_of_documents=1):
tree = self.get_all_filings(filing_type="10-K")
elems = tree.xpath('//*[@id="documentsbutton"]')[:no_of_documents]
result = []
for elem in elems:
url = BASE_URL + elem.attrib["href"]
content_page = get_request(url)
table = content_page.find_class("tableFile")[0]
for row in table.getchildren():
if row.getchildren()[3].text == document_type:
href = row.getchildren()[2].getchildren()[0].attrib["href"]
href = BASE_URL + href
doc = get_request(href)
result.append(doc)
return result

def get_10Ks(self, no_of_documents=1):
tree = self.get_all_filings(filing_type="10-K")
elems = tree.xpath('//*[@id="documentsbutton"]')[:no_of_documents]
Expand Down

0 comments on commit 94bae45

Please sign in to comment.