title: Getting 'NoneType' object has no attribute 'text' error with BeautifulSoup
body: <p>I am new to the python and dyjango. I am trying to make a <strong>scraper</strong> using BeautifulSoup. My site has a search form where user searches for products that am using BeautifulSoup to <strong>scrape</strong> amazon.in to show the results to the user.</p>
  <p>Everything works fine but it gives me two types of error sometime it gives me the error:</p>
  <pre><code>File &quot;C:\Users\Ahmed\Anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py&quot;, line 383, in execute
      return Database.Cursor.execute(self, query, params)
  sqlite3.IntegrityError: NOT NULL constraint failed: myapp_search.search
  
  The above exception was the direct cause of the following exception:
  </code></pre>
  <p>and sometimes it gives the error:</p>
  <pre><code>File &quot;C:\Users\Ahmed\codelist\myapp\views.py&quot;, line 24, in new_search
      post_title = post.find(class_='a-section').text
  AttributeError: 'NoneType' object has no attribute 'text'
  [15/Mar/2020 13:34:15] &quot;POST /new_search HTTP/1.1&quot; 500 87165
  </code></pre>
  <p>my <strong>views.py</strong></p>
  <pre><code>import requests
  from bs4 import BeautifulSoup
  from django.shortcuts import render
  from requests.compat import quote_plus
  from . import models
  
  BASE_AMAZON_URL = 'https://www.amazon.in/s?k={}'
  
  def home(request):
      return render(request, 'base.html')
  
  def new_search(request):
      search = request.POST.get('search')
      models.Search.objects.create(search=search)
      final_url = BASE_AMAZON_URL.format(quote_plus(search))
      response = requests.get(final_url)
      data = response.text
      soup = BeautifulSoup(data, features='html.parser')
  
      post_listings = soup.find_all('', {'class': 's-result-list'})
  
      final_postings = []
      for post in post_listings:
          post_title = post.find(class_='a-section').text
          post_url = post.find('a').get('href')
          post_price = post.find(class_='a-price').text
  
          final_postings.append((post_title, post_url, post_price))
  
      stuff_for_frontend = {
      'search': search,
      'final_postings': final_postings,
      }
      return render(request, 'myapp/new_search.html', stuff_for_frontend)
  </code></pre>
  <p>my <strong>new_search.html</strong></p>
  <pre><code>{% extends 'base.html' %}
  
  {% block content %}
      &lt;h2 style=&quot;text-align: center;&quot;&gt;{{ search | title }}&lt;/h2&gt;
  
      {% for post in final_postings %}
      &lt;p&gt;{{ post.0 }}&lt;/p&gt;
      &lt;p&gt;{{ post.1 }}&lt;/p&gt;
      &lt;p&gt;{{ post.2 }}&lt;/p&gt;
      {% endfor %}
  
  
  {% endblock content %}
  </code></pre>