From b2f89b199d06ab856fa5a54556d9ff5ab5fcd829 Mon Sep 17 00:00:00 2001 From: Thirumalai Raj R Date: Sat, 14 Oct 2023 13:37:41 +0530 Subject: [PATCH 1/3] [Hotfix] Finviz Title DOM Changes --- finviz/main_func.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/finviz/main_func.py b/finviz/main_func.py index a39596e..b94a794 100644 --- a/finviz/main_func.py +++ b/finviz/main_func.py @@ -32,13 +32,16 @@ def get_stock(ticker): get_page(ticker) page_parsed = STOCK_PAGE[ticker] - title = page_parsed.cssselect('table[class="fullview-title"]')[0] - keys = ["Ticker","Company", "Sector", "Industry", "Country"] - fields = [f.text_content() for f in title.cssselect('a[class="tab-link"]')] - data = dict(zip(keys, fields)) - - company_link = title.cssselect('a[class="tab-link"]')[0].attrib["href"] + title = page_parsed.cssselect('div[class="fv-container py-2.5"]')[0] + data = {} + data["Ticker"] = title.cssselect('h1[class="quote-header_ticker-wrapper_ticker"]')[0].text_content() + company_details = title.cssselect('h2[class="quote-header_ticker-wrapper_company"]')[0] + data["Company"] = company_details.text_content().strip() + company_link = company_details.cssselect('a[class="tab-link block truncate"]')[0].attrib["href"] data["Website"] = company_link if company_link.startswith("http") else None + keys = ["Sector", "Industry", "Country", "Exchange"] + fields = [f.text_content() for f in title.cssselect('a[class="tab-link"]')] + data.update(dict(zip(keys, fields))) all_rows = [ row.xpath("td//text()") From e88e888b91507928f8a1f4fdbcb727acad5b4bf0 Mon Sep 17 00:00:00 2001 From: Thirumalai Raj R Date: Sat, 14 Oct 2023 13:45:07 +0530 Subject: [PATCH 2/3] Incremental changes --- finviz/main_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/finviz/main_func.py b/finviz/main_func.py index b94a794..6b5cb3e 100644 --- a/finviz/main_func.py +++ b/finviz/main_func.py @@ -34,7 +34,7 @@ def get_stock(ticker): title = page_parsed.cssselect('div[class="fv-container py-2.5"]')[0] data = {} - data["Ticker"] = title.cssselect('h1[class="quote-header_ticker-wrapper_ticker"]')[0].text_content() + data["Ticker"] = title.cssselect('h1[class="quote-header_ticker-wrapper_ticker"]')[0].text_content().strip() company_details = title.cssselect('h2[class="quote-header_ticker-wrapper_company"]')[0] data["Company"] = company_details.text_content().strip() company_link = company_details.cssselect('a[class="tab-link block truncate"]')[0].attrib["href"] From d50842fb143d96ee062a48d6a4d88083cc42ac09 Mon Sep 17 00:00:00 2001 From: Mahanya Kochhar Date: Thu, 19 Oct 2023 00:57:23 +0530 Subject: [PATCH 3/3] finviz-list-index-fix --- finviz/main_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/finviz/main_func.py b/finviz/main_func.py index 6b5cb3e..9645ce3 100644 --- a/finviz/main_func.py +++ b/finviz/main_func.py @@ -34,7 +34,7 @@ def get_stock(ticker): title = page_parsed.cssselect('div[class="fv-container py-2.5"]')[0] data = {} - data["Ticker"] = title.cssselect('h1[class="quote-header_ticker-wrapper_ticker"]')[0].text_content().strip() + data["Ticker"] = title.cssselect('h1[class="js-recent-quote-ticker quote-header_ticker-wrapper_ticker"]')[0].text_content().strip() company_details = title.cssselect('h2[class="quote-header_ticker-wrapper_company"]')[0] data["Company"] = company_details.text_content().strip() company_link = company_details.cssselect('a[class="tab-link block truncate"]')[0].attrib["href"]