title: AttributeError: 'NoneType' object has no attribute 'tbody' - Spyder 3.3.1 / beautifulsoup4 / python 3.6
body: <p>Hey this is my setup: Spyder 3.3.1 / beautifulsoup4 / python 3.6</p>
  
  <p>The below code is from an article on medium (<a href="https://towardsdatascience.com/a-short-practical-how-to-guide-to-scrape-data-from-a-website-using-python-888373227d4f" rel="nofollow noreferrer">here</a>) about webscraping with python and Beautifulsoup. Was supposed to be a quick read but now TWO days later I still cant not get the code to run in spyder and keep getting: </p>
  
  <pre><code>File "/Users/xxxxxxx/Documents/testdir/swiftScrape.py", line 9, in table_to_df
      return pd.DataFrame([[td.text for td in row.findAll('td')] for row in table.tbody.findAll('tr')])
  
  AttributeError: 'NoneType' object has no attribute 'tbody'
  </code></pre>
  
  <p>Not sure what is going wrong and seems to be an implementation error. Can anyone assist in sheding some light on this issue.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>import os
  import bs4
  import requests
  import pandas as pd
  
  PATH = os.path.join("C:\\","Users","xxxxx","Documents","tesdir")
  
  def table_to_df(table):
      return pd.DataFrame([[td.text for td in row.findAll('td')] for row in table.tbody.findAll('tr')])
  
  def next_page(soup):
      return "http:" + soup.find('a', attrs={'rel':'next'}).get('href')
  
  res = pd.DataFrame()
  url = "http://bank-code.net/country/FRANCE-%28FR%29/"
  counter = 0
  
  while True:
      print(counter)
      page = requests.get(url)
      soup = bs4.BeautifulSoup(page.content, 'lxml')
      table = soup.find(name='table', attrs={'id':'tableID'})
      res = res.append(table_to_df(table))
      res.to_csv(os.path.join(PATH,"BIC","table.csv"), index=None, sep=';', encoding='iso-8859-1')
      url = next_page(soup)
      counter += 1
  </code></pre>