title: AttributeError at / 'NoneType' object has no attribute 'strip', why and how? stuck here for a while
body: <p>why am I getting this error? something wrong with my media? or with views? below is Media I;m using goose extractor to try to extract the image from the user posted url, maybe I did something wrong there I simply followed here: <a href="https://docs.python.org/2/howto/urllib2.html" rel="nofollow">https://docs.python.org/2/howto/urllib2.html</a></p>
  
  <p>media.py</p>
  
  <pre><code>import json
  import urllib2
  from urllib2 import Request
  from goose import Goose
  
  def get_content(url):
  
      req = urllib2.Request(url)
      response = urllib2.Request.urlopen(req).read()
      return response 
  
  
  def extract(url):
      url = get_content(url)
      g = Goose()
      article = g.extract(url=url)
      resposne = {'image':article.top_image.src}
      return json.dumps(resposne)
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def index(request):
          categories = Category.objects.all()
          url = request.GET.get('url')
          image = extract(url)
          try:
                  sort = request.GET["sort"].strip
                  sort_method = SortMethods[sort]
                  page = request.GET["page"].strip()
          except KeyError:
                  sort_method = SortMethods.score
                  page = 1
  
          if sort_method == SortMethods.date:
                  thread_list = Post.objects.order_by("-pub_date")
          else:
                  thread_list = Post.objects.all()
                  thread_list = sorted(thread_list, key=lambda x: x.get_score(), reverse=True)
  
          paginator = Paginator(thread_list, 30)
  
          try:
                  posts = paginator.page(page)
          except PageNotAnInteger:
                  posts = paginator.page(1)
          except EmptyPage:
                  posts = paginator.page(paginator.num_pages)
  
          context = {
                  "posts": posts,
                  "pages": paginator.page_range,
                  "sort": sort_method.name,
                  "categories":categories,
                  "image":image
          }
          return render(request, "main/index.html", context)
  </code></pre>