TopDownHockey-Scraper 3.2.2__tar.gz → 3.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of TopDownHockey-Scraper might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: TopDownHockey_Scraper
3
- Version: 3.2.2
3
+ Version: 3.2.4
4
4
  Summary: The TopDownHockey Scraper
5
5
  Home-page: https://github.com/TopDownHockey/TopDownHockey_Scraper
6
6
  Author: Patrick Bacon
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = TopDownHockey_Scraper
3
- version = 3.2.2
3
+ version = 3.2.4
4
4
  author = Patrick Bacon
5
5
  author_email = patrick.s.bacon@gmail.com
6
6
  description = A package built for scraping hockey data from EliteProspects, the NHL's HTML/API reports, and ESPN's XML reports.
@@ -9,7 +9,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
9
9
 
10
10
  setup(
11
11
  name="TopDownHockey_Scraper", # Replace with your own username
12
- version="3.2.2",
12
+ version="3.2.4",
13
13
  author="Patrick Bacon",
14
14
  author_email="patrick.s.bacon@gmail.com",
15
15
  description="The TopDownHockey Scraper",
@@ -1872,6 +1872,7 @@ def scrape_espn_events(espn_game_id, drop_description = True):
1872
1872
  return espn_events
1873
1873
 
1874
1874
  def scrape_espn_ids_single_game(game_date, home_team, away_team):
1875
+
1875
1876
  gamedays = pd.DataFrame()
1876
1877
 
1877
1878
  if home_team == 'ATLANTA THRASHERS':
@@ -1896,33 +1897,29 @@ def scrape_espn_ids_single_game(game_date, home_team, away_team):
1896
1897
  gids = []
1897
1898
  fax = pd.DataFrame()
1898
1899
  #print(str(i))
1899
- for i in range (0, (int(len(soup_found)/3))):
1900
- away = soup_found[0 + (i * 3)]['href'].rsplit('/')[-2].upper()
1901
- home = soup_found[1 + (i * 3)]['href'].rsplit('/')[-2].upper()
1902
- espnid = soup_found[2 + (i * 3)]['href'].split('gameId/', 1)[1]
1900
+ for i in range (0, ((len(soup_found)))):
1901
+ away = soup_found[i]['href'].rsplit('/')[-1].split('-')[0].upper()
1902
+ home = soup_found[i]['href'].rsplit('/')[-1].split('-')[1].upper()
1903
+ espnid = soup_found[i]['href'].rsplit('/')[-2]
1903
1904
  at.append(away)
1904
1905
  ht.append(home)
1905
1906
  gids.append(espnid)
1906
-
1907
+
1907
1908
  fax = fax.assign(
1908
1909
  away_team = at,
1909
1910
  home_team = ht,
1910
1911
  espn_id = gids,
1911
1912
  game_date = pd.to_datetime(this_date))
1912
-
1913
+
1913
1914
  gamedays = gamedays._append(fax)
1914
-
1915
+
1915
1916
  gamedays = gamedays.assign(
1916
1917
  home_team = np.where(gamedays.home_team=='ST LOUIS BLUES', 'ST. LOUIS BLUES', gamedays.home_team),
1917
1918
  away_team = np.where(gamedays.away_team=='ST LOUIS BLUES', 'ST. LOUIS BLUES', gamedays.away_team),
1918
1919
  espn_id = gamedays.espn_id.str.split('/').str[0].astype(int)
1919
-
1920
+
1920
1921
  )
1921
- #gamedays = gamedays.assign(
1922
- # home_team = np.where(gamedays.home_team=='WINNIPEG JETS', 'ATLANTA THRASHERS', gamedays.home_team),
1923
- # away_team = np.where(gamedays.away_team=='WINNIPEG JETS', 'ATLANTA THRASHERS', gamedays.away_team),
1924
- # espn_id = gamedays.espn_id.astype(int))
1925
-
1922
+
1926
1923
  gamedays = gamedays.assign(
1927
1924
  home_team = np.where(gamedays.home_team=='TB', 'TBL',
1928
1925
  np.where(gamedays.home_team=='T.B', 'TBL',
@@ -1944,7 +1941,79 @@ def scrape_espn_ids_single_game(game_date, home_team, away_team):
1944
1941
  gamedays.away_team)))))))),
1945
1942
  espn_id = gamedays.espn_id.astype(int))
1946
1943
 
1947
- gamedays = gamedays[(gamedays.game_date==this_date) & (gamedays.home_team==home_team) & (gamedays.away_team==away_team)]
1944
+ gamedays = gamedays.assign(
1945
+ away_team = np.where(gamedays.away_team=='DUCKS', 'ANA',
1946
+ np.where(gamedays.away_team=='COYOTES', 'ARI',
1947
+ np.where(gamedays.away_team=='BRUINS', 'BOS',
1948
+ np.where(gamedays.away_team=='SABRES', 'BUF',
1949
+ np.where(gamedays.away_team=='FLAMES', 'CGY',
1950
+ np.where(gamedays.away_team=='HURRICANES', 'CAR',
1951
+ np.where(gamedays.away_team=='BLACKHAWKS', 'CHI',
1952
+ np.where(gamedays.away_team=='AVALANCHE', 'COL',
1953
+ np.where(gamedays.away_team=='BLUE JACKETS', 'CBJ',
1954
+ np.where(gamedays.away_team=='STARS', 'DAL',
1955
+ np.where(gamedays.away_team=='RED WINGS', 'DET',
1956
+ np.where(gamedays.away_team=='OILERS', 'EDM',
1957
+ np.where(gamedays.away_team=='PANTHERS', 'FLA',
1958
+ np.where(gamedays.away_team=='KINGS', 'LAK',
1959
+ np.where(gamedays.away_team=='WILD', 'MIN',
1960
+ np.where(gamedays.away_team=='CANADIENS', 'MTL',
1961
+ np.where(gamedays.away_team=='PREDATORS', 'NSH',
1962
+ np.where(gamedays.away_team=='DEVILS', 'NJD',
1963
+ np.where(gamedays.away_team=='ISLANDERS', 'NYI',
1964
+ np.where(gamedays.away_team=='RANGERS', 'NYR',
1965
+ np.where(gamedays.away_team=='SENATORS', 'OTT',
1966
+ np.where(gamedays.away_team=='FLYERS', 'PHI',
1967
+ np.where(gamedays.away_team=='PENGUINS', 'PIT',
1968
+ np.where(gamedays.away_team=='SHARKS', 'SJS',
1969
+ np.where(gamedays.away_team=='KRAKEN', 'SEA',
1970
+ np.where(gamedays.away_team=='BLUES', 'STL',
1971
+ np.where(gamedays.away_team=='LIGHTNING', 'TBL',
1972
+ np.where(gamedays.away_team=='MAPLE LEAFS', 'TOR',
1973
+ np.where(gamedays.away_team=='CANUCKS', 'VAN',
1974
+ np.where(gamedays.away_team=='GOLDEN KNIGHTS', 'VGK',
1975
+ np.where(gamedays.away_team=='CAPITALS', 'WSH',
1976
+ np.where(gamedays.away_team=='JETS', 'WPG', 'mistake'
1977
+ ))))))))))))))))))))))))))))))))
1978
+ )
1979
+
1980
+ gamedays = gamedays.assign(
1981
+ home_team = np.where(gamedays.home_team=='DUCKS', 'ANA',
1982
+ np.where(gamedays.home_team=='COYOTES', 'ARI',
1983
+ np.where(gamedays.home_team=='BRUINS', 'BOS',
1984
+ np.where(gamedays.home_team=='SABRES', 'BUF',
1985
+ np.where(gamedays.home_team=='FLAMES', 'CGY',
1986
+ np.where(gamedays.home_team=='HURRICANES', 'CAR',
1987
+ np.where(gamedays.home_team=='BLACKHAWKS', 'CHI',
1988
+ np.where(gamedays.home_team=='AVALANCHE', 'COL',
1989
+ np.where(gamedays.home_team=='BLUE JACKETS', 'CBJ',
1990
+ np.where(gamedays.home_team=='STARS', 'DAL',
1991
+ np.where(gamedays.home_team=='RED WINGS', 'DET',
1992
+ np.where(gamedays.home_team=='OILERS', 'EDM',
1993
+ np.where(gamedays.home_team=='PANTHERS', 'FLA',
1994
+ np.where(gamedays.home_team=='KINGS', 'LAK',
1995
+ np.where(gamedays.home_team=='WILD', 'MIN',
1996
+ np.where(gamedays.home_team=='CANADIENS', 'MTL',
1997
+ np.where(gamedays.home_team=='PREDATORS', 'NSH',
1998
+ np.where(gamedays.home_team=='DEVILS', 'NJD',
1999
+ np.where(gamedays.home_team=='ISLANDERS', 'NYI',
2000
+ np.where(gamedays.home_team=='RANGERS', 'NYR',
2001
+ np.where(gamedays.home_team=='SENATORS', 'OTT',
2002
+ np.where(gamedays.home_team=='FLYERS', 'PHI',
2003
+ np.where(gamedays.home_team=='PENGUINS', 'PIT',
2004
+ np.where(gamedays.home_team=='SHARKS', 'SJS',
2005
+ np.where(gamedays.home_team=='KRAKEN', 'SEA',
2006
+ np.where(gamedays.home_team=='BLUES', 'STL',
2007
+ np.where(gamedays.home_team=='LIGHTNING', 'TBL',
2008
+ np.where(gamedays.home_team=='MAPLE LEAFS', 'TOR',
2009
+ np.where(gamedays.home_team=='CANUCKS', 'VAN',
2010
+ np.where(gamedays.home_team=='GOLDEN KNIGHTS', 'VGK',
2011
+ np.where(gamedays.home_team=='CAPITALS', 'WSH',
2012
+ np.where(gamedays.home_team=='JETS', 'WPG', 'mistake'
2013
+ ))))))))))))))))))))))))))))))))
2014
+ )
2015
+
2016
+ gamedays = gamedays[(gamedays.game_date==this_date) & (gamedays.home_team==home_team) & (gamedays.away_team==away_team)]
1948
2017
 
1949
2018
  return(gamedays)
1950
2019
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: TopDownHockey_Scraper
3
- Version: 3.2.2
3
+ Version: 3.2.4
4
4
  Summary: The TopDownHockey Scraper
5
5
  Home-page: https://github.com/TopDownHockey/TopDownHockey_Scraper
6
6
  Author: Patrick Bacon