Forums

pd.read_html(r.text) works in PyCharm but not PythonAnywhere. No tables found error

Code:

header =  {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.26
61.75 Safari/537.36", "X-Requested-With": "XMLHttpRequest" }

url = "http://www.naturalstattrick.com/teamtable.php?fromseason={}&thruseason= 
{}&stype=2&sit=all&score=all".format(20212022, 20212022)

r = requests.get(url, headers=header)
df = pd.read_html(r.text, index_col=0, header=0)[0]
print(df)

PythonAnywhere Output:

ValueError: No tables found

PyCharm Output:

              Team  GP        TOI   W  ...  LDSV%    SH%    SV%    PDO
1           Anaheim Ducks  49  3004.3000  23  ...  96.38   9.62  91.55  1.012
2         Arizona Coyotes  48  2910.9667  12  ...  95.07   8.60  89.29  0.979
3           Boston Bruins  46  2776.7833  27  ...  96.50   8.26  90.42  0.987
4          Buffalo Sabres  46  2791.2500  14  ...  96.48   8.85  90.02  0.989

Is there anything Im doing wrong? I thought it might be that the website doesn't allow for scraping but I cant scrape from ESPN.com either.

Any help is much appreciated

Take a look at r.text in both cases.