From 542e57de340c10635ecb5bc53b4a90132006c49a Mon Sep 17 00:00:00 2001 From: lottopy Date: Mon, 29 Jul 2024 11:15:31 -0400 Subject: [PATCH] updated script to no longer pass literal string to read_html using StringIO as behavior is to be deprecated soon in pandas --- cash25.py | 4 +++- daily3.py | 4 +++- daily4.py | 4 +++- lotto_america.py | 4 +++- lottopy_pb.py | 4 +++- megamil.py | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cash25.py b/cash25.py index 7406d13..1d47273 100755 --- a/cash25.py +++ b/cash25.py @@ -3,6 +3,8 @@ from fractions import Fraction as frac import pandas as pd import requests from collections import Counter +from io import StringIO + def get_data(): # old data from WVLottery.com @@ -17,7 +19,7 @@ def get_data(): # Get web data r = requests.get(url, headers=header) - dfs = list(pd.read_html(r.text)) + dfs = list(pd.read_html(StringIO(r.text))) pd.set_option('display.max_rows', None) # Specifies no max rows, otherwise only shows 10 records df = pd.concat([dfs[0], salvaged], ignore_index=True) diff --git a/daily3.py b/daily3.py index b737b8c..b964ba1 100755 --- a/daily3.py +++ b/daily3.py @@ -3,6 +3,8 @@ from fractions import Fraction as frac import pandas as pd import requests from collections import Counter +from io import StringIO + def get_data(): url = 'https://wvlottery.com/draw-games/daily-3/?game-analyze=daily-3&what-to-search=historysearch&date-range=-1' @@ -12,7 +14,7 @@ def get_data(): } # Get web data r = requests.get(url, headers=header) - dfs = pd.read_html(r.text) + dfs = list(pd.read_html(StringIO(r.text))) pd.set_option('display.max_rows', None) # Specifies no max rows, otherwise only shows 10 records df = dfs[0] diff --git a/daily4.py b/daily4.py index d61d140..ea8ec3d 100755 --- a/daily4.py +++ b/daily4.py @@ -3,6 +3,8 @@ from fractions import Fraction as frac import pandas as pd import requests from collections import Counter +from io import StringIO + def get_data(): # Old data from WVLottery.com @@ -16,7 +18,7 @@ def get_data(): } # Get web data r = requests.get(url, headers=header) - dfs = list(pd.read_html(r.text)) + dfs = list(pd.read_html(StringIO(r.text))) pd.set_option('display.max_rows', None) # Specifies no max rows, otherwise only shows 10 records df = pd.concat([dfs[0], salvaged], ignore_index=True) diff --git a/lotto_america.py b/lotto_america.py index 8658445..746fff6 100755 --- a/lotto_america.py +++ b/lotto_america.py @@ -3,6 +3,8 @@ from fractions import Fraction as frac import pandas as pd import requests from collections import Counter +from io import StringIO + def get_data(): df_old = pd.read_excel('./excel_lotto_records/lotto_america.xlsx') @@ -16,7 +18,7 @@ def get_data(): # Get web data r = requests.get(url, headers=header) - dfs = list(pd.read_html(r.text)) + dfs = list(pd.read_html(StringIO(r.text))) pd.set_option('display.max_rows', None) # Specifies no max rows, otherwise only shows 10 records df = pd.concat([dfs[0], salvaged], ignore_index=True) diff --git a/lottopy_pb.py b/lottopy_pb.py index 20b439f..e716908 100755 --- a/lottopy_pb.py +++ b/lottopy_pb.py @@ -17,7 +17,9 @@ def get_data(): } # Get web data r = requests.get(url, headers=header) - dfs = list(pd.read_html(r.text)) + from io import StringIO + + dfs = list(pd.read_html(StringIO(r.text))) pd.set_option('display.max_rows', None) # Specifies no max rows, otherwise only shows 10 records df = pd.concat([dfs[0], salvaged], ignore_index=True) diff --git a/megamil.py b/megamil.py index 823f80e..9c08b2d 100755 --- a/megamil.py +++ b/megamil.py @@ -3,6 +3,8 @@ from fractions import Fraction as frac import pandas as pd import requests from collections import Counter +from io import StringIO + def get_data(): # previous records which have since been removed from wvlottery.com's database @@ -17,7 +19,7 @@ def get_data(): # Get web data r = requests.get(url, headers=header) - dfs = list(pd.read_html(r.text)) + dfs = list(pd.read_html(StringIO(r.text))) pd.set_option('display.max_rows', None) # Specifies no max rows, otherwise only shows 10 records df = pd.concat([dfs[0], salvaged], ignore_index=True)