summarylogtreecommitdiffstats
path: root/72.patch
blob: ac34ac7334216ac02d0088017aa3cf41b69b56f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From 5805c54f96c9222e587603d49130a7c0e710480b Mon Sep 17 00:00:00 2001
From: Sylvan Butler <gitstuff.sylvan@xoxy.net>
Date: Fri, 6 Mar 2020 19:55:52 -0700
Subject: [PATCH 1/3] yahoo issue was the client version

---
 yahoofinancials/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/yahoofinancials/__init__.py b/yahoofinancials/__init__.py
index 294392b..797a89b 100644
--- a/yahoofinancials/__init__.py
+++ b/yahoofinancials/__init__.py
@@ -68,7 +68,7 @@ class ManagedException(Exception):
 
 # Class used to open urls for financial data
 class UrlOpener(FancyURLopener):
-    version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'
+    version = 'w3m/0.5.3+git20180125'
 
 
 # Class containing Yahoo Finance ETL Functionality

From 5a5566d5de0328e4e799d443b315a5d829a09fe8 Mon Sep 17 00:00:00 2001
From: Sylvan Butler <gitstuff.sylvan@xoxy.net>
Date: Fri, 24 Apr 2020 09:38:39 -0600
Subject: [PATCH 2/3] fix for bs4 4.9.0 script change

preserves compatibility with prior versions
---
 yahoofinancials/__init__.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/yahoofinancials/__init__.py b/yahoofinancials/__init__.py
index 797a89b..bd0f885 100644
--- a/yahoofinancials/__init__.py
+++ b/yahoofinancials/__init__.py
@@ -150,6 +150,9 @@ def _scrape_data(self, url, tech_type, statement_type):
                     re_script = soup.find("script", text=re.compile("root.App.main"))
                     if re_script is not None:
                         script = re_script.text
+                        # bs4 4.9.0 changed so text from scripts is no longer considered text
+                        if not script:
+                            script = re_script.string
                         self._cache[url] = loads(re.search("root.App.main\s+=\s+(\{.*\})", script).group(1))
                         response.close()
                         break

From e36587b928c00b69f3876187aa15ab48818bccc8 Mon Sep 17 00:00:00 2001
From: Sylvan Butler <gitstuff.sylvan@xoxy.net>
Date: Fri, 6 Mar 2020 20:16:51 -0700
Subject: [PATCH 3/3] fix test for 2020 adjclose

---
 test/test_yahoofinancials.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/test_yahoofinancials.py b/test/test_yahoofinancials.py
index 2b79bc6..bcb6c73 100644
--- a/test/test_yahoofinancials.py
+++ b/test/test_yahoofinancials.py
@@ -83,8 +83,10 @@ def test_yf_fundamentals(self):
     def test_yf_historical_price(self):
         single_stock_prices = self.test_yf_stock_single.get_historical_price_data('2015-01-15', '2017-10-15', 'weekly')
         expect_dict = {'high': 49.099998474121094, 'volume': 125737200, 'formatted_date': '2015-01-12',
-                       'low': 46.599998474121094, 'adjclose': 45.35684585571289, 'date': 1421038800,
+                       'low': 46.599998474121094, 'date': 1421038800,
                        'close': 47.61000061035156, 'open': 48.959999084472656}
+        # ignore adjclose as it will change with every dividend paid in the future
+        del single_stock_prices['C']['prices'][0]['adjclose']
         self.assertDictEqual(single_stock_prices['C']['prices'][0], expect_dict)
 
     # Historical Stock Daily Dividend Test