title: Scraping box ccores with BeautifulSoup and using pandas to export to Excel
body: <p>I've been trying to figure out how to scrape baseball box scores from Fangraphs with Python 3.6 and the BeautifulSoup and Pandas modules. My final goal is to save different sections of the webpage to different sheets in Excel. </p>
  
  <p>In order to do this, I think I have to pull each table separately by their respective id tags. This is the code to do so for the four tables (below the graph on the page) that would make up the first excel sheet. Running the code results in this error:</p>
  
  <pre><code>Traceback (most recent call last):
  
  File "Fangraphs Box Score Scraper.py", line 14, in &lt;module&gt;
  df1 = pd.read_html(soup,attrs={'id': ['WinsBox1_dghb','WinsBox1_dghp','WinsBox1_dgab','WinsBox1_dgap']})
  
  File "C:\Python36\lib\site-packages\pandas\io\html.py", line 906, in read_html
  keep_default_na=keep_default_na)
  
  File "C:\Python36\lib\site-packages\pandas\io\html.py", line 743, in _parse
  raise_with_traceback(retained)
  
  File "C:\Python36\lib\site-packages\pandas\compat\__init__.py", line 344, in raise_with_traceback
  
  raise exc.with_traceback(traceback)
  
  TypeError: 'NoneType' object is not callable
  </code></pre>
  
  <hr>
  
  <pre><code>import requests
  from bs4 import BeautifulSoup
  import pandas as pd
  
  url = 'http://www.fangraphs.com/boxscore.aspx?date=2017-09-10&amp;team=Red%20Sox&amp;dh=0&amp;season=2017'
  response = requests.get(url)
  soup = BeautifulSoup(response.text,"lxml")
  
  df1 = pd.read_html(soup,attrs={'id': ['WinsBox1_dghb','WinsBox1_dghp','WinsBox1_dgab','WinsBox1_dgap']})
  
  writer = pd.ExcelWriter('Box Scores.xlsx')
  df1.to_excel(writer,'Traditional Box Scores')
  </code></pre>