title: BeautifulSoup not defined when called in function
body: <p>My web scraper is throwing <code>NameError: name 'BeautifulSoup' is not defined</code> when I call BeautifulSoup() inside my function, but it works normally when I call it outside the function and pass the Soup as an argument. </p>
  
  <p>Here is the working code:</p>
  
  <pre><code>from teams.models import *
  from bs4 import BeautifulSoup
  from django.conf import settings
  import requests, os, string
  
  soup = BeautifulSoup(open(os.path.join(settings.BASE_DIR, 'revolver.html')), 'html.parser')
  
  def scrapeTeamPage(soup):
      teamInfo = soup.find('div', 'profile_info')
  ...
  print(scrapeTeamPage(soup))
  </code></pre>
  
  <p>But when I move the BeautifulSoup call inside my function, I get the error.</p>
  
  <pre><code>from teams.models import *
  from bs4 import BeautifulSoup
  from django.conf import settings
  import requests, os, string
  
  def scrapeTeamPage(url):
      soup = BeautifulSoup(open(os.path.join(settings.BASE_DIR, url)), 'html.parser')
      teamInfo = soup.find('div', 'profile_info')
  </code></pre>