Skip to content

Commit

Permalink
forces utf-8 encoding (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdilday authored Jul 18, 2021
1 parent 0915652 commit 582981c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pybaseball/league_batting_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def get_soup(start_dt: date, end_dt: date) -> BeautifulSoup:
# return None
url = "http://www.baseball-reference.com/leagues/daily.cgi?user_team=&bust_cache=&type=b&lastndays=7&dates=fromandto&fromandto={}.{}&level=mlb&franch=&stat=&stat_value=0".format(start_dt, end_dt)
s = requests.get(url).content
return BeautifulSoup(s, "lxml")
# a workaround to avoid beautiful soup applying the wrong encoding
s = str(s).encode()
return BeautifulSoup(s, features="lxml")


def get_table(soup: BeautifulSoup) -> pd.DataFrame:
Expand Down
4 changes: 3 additions & 1 deletion pybaseball/league_pitching_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def get_soup(start_dt, end_dt):
return None
url = "http://www.baseball-reference.com/leagues/daily.cgi?user_team=&bust_cache=&type=p&lastndays=7&dates=fromandto&fromandto={}.{}&level=mlb&franch=&stat=&stat_value=0".format(start_dt, end_dt)
s = requests.get(url).content
return BeautifulSoup(s, "lxml")
# a workaround to avoid beautiful soup applying the wrong encoding
s = str(s).encode()
return BeautifulSoup(s, features="lxml")


def get_table(soup):
Expand Down

0 comments on commit 582981c

Please sign in to comment.