more tests, idea for change

This commit is contained in:
2021-11-26 12:47:58 +01:00
parent 1e0410a254
commit 776c909956
3 changed files with 122 additions and 28 deletions

View File

@ -1,3 +1,14 @@
HTML_PARSER = 'html.parser'
DOMAIN = 'www.marketwatch.com'
BASE_URL = f'https://{DOMAIN}/investing/stock'
BS, IS, CF = 'bs', 'is', 'cf'
FIN_STMT_URL_SUFFIX = {
BS: '/balance-sheet',
IS: '',
CF: '/cash-flow'
}
# All items marked `False` do not need to be scraped
# because they are calculated from other items (e.g. growth or ratios).
FINANCIAL_STATEMENT_ITEMS = {

View File

@ -11,8 +11,6 @@ from bs4.element import ResultSet, Tag
# the end dates of the reporting periods as strings (either years or quarters).
ResultDict = dict[str, Union[tuple[int], tuple[str]]]
HTML_PARSER = 'html.parser'
async def soup_from_url(url: str, session: ClientSession = None) -> BeautifulSoup:
"""
@ -58,6 +56,14 @@ def extract_all_data(soup: BeautifulSoup) -> ResultDict:
pass
async def _get_financial_statement(statement: str, ticker_symbol: str, yearly: bool = True, quarterly: bool = True,
session: ClientSession = None) -> ResultDict:
"""
Returns data from the specified financial statement of the specified company.
"""
pass # TODO: Don't allow both yearly and quarterly, instead only have `quarterly` Flag
async def get_balance_sheet(ticker_symbol: str, yearly: bool = True, quarterly: bool = True,
session: ClientSession = None) -> ResultDict:
"""