title: how to create a django app that performs a google search
body: <p>I want to make a Django app that searches on google a string and then saves the html page.</p>
  <p>so far I managed to</p>
  <p>create this</p>
  <pre><code>&lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC&quot; crossorigin=&quot;anonymous&quot;&gt;
  
  
  
  
  
  &lt;div class=&quot;container text-center&quot;&gt;
      &lt;h1&gt;my search engine&lt;/h1&gt;
      &lt;h3&gt;Pressing search will run a google search for 'lallero search', then the code will scrape the first 5 links in that google search and store the corresponding html.&lt;/h3&gt;
      &lt;a href=&quot;{% url 'about' %}&quot;&gt;About page&lt;/a&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;form action=&quot;{% url 'search' %}&quot;&gt;
  
  
  
      &lt;input type='submit' value='search' class=&quot;btn btn-primary&quot;&gt;
  
  
  
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  <p>that searches on google a very specific string and it is just a press button.
  I would like to add a form where I can write the string I want to search and then pass it as input to my &quot;search&quot; function</p>
  <p>so far I came out with this</p>
  <pre><code>    &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC&quot; crossorigin=&quot;anonymous&quot;&gt;
  
  
  &lt;div class=&quot;container text-center&quot;&gt;
      &lt;h1&gt;my search engine&lt;/h1&gt;
      &lt;a href=&quot;{% url 'about' %}&quot;&gt;About page&lt;/a&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;form action=&quot;{% url 'search' %}&quot;&gt;
  
    &lt;input type=&quot;search&quot; value='lallero search' class=&quot;form-control rounded&quot; placeholder=&quot;Search&quot; aria-label=&quot;Search&quot;
      aria-describedby=&quot;search-addon&quot; /&gt;
    &lt;button type=&quot;button&quot; class=&quot;btn btn-outline-primary&quot;&gt;search&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  <p>but I do not know how to pass the string I write as input to the function.</p>
  <p>any advice?</p>
  <p>--------------------update</p>
  <p>Following comments, I put the SearchForm into a utils file that I import and then I changed my search function to</p>
  <pre><code>def search(request):
      form = SearchForm(request.GET)
      if form.is_valid():  # this will validate your form
          search_text = form.cleaned_data[&quot;search&quot;]  # now you can access input
      urls = searchWeb(num=5, stop=5, query_string=search_text)
  
      threads = [threading.Thread(target=getSavePage, args=(url,)) for url in urls]
      for thread in threads:
          thread.start()
      for thread in threads:
          thread.join()
      return JsonResponse(urls, safe=False)
  </code></pre>
  <p>I changed my template to</p>
  <pre><code>&lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC&quot; crossorigin=&quot;anonymous&quot;&gt;
  
  
  
  
  
  
  &lt;div class=&quot;container text-center&quot;&gt;
      &lt;h1&gt;my search engine&lt;/h1&gt;
      &lt;a href=&quot;{% url 'about' %}&quot;&gt;About page&lt;/a&gt;
      &lt;br&gt;
      &lt;br&gt;
  
      &lt;form action=&quot;{% url 'search' %}&quot;&gt;
      {{ form.non_field_errors }}
      {{ form.as_p }} &lt;!-- This will create a text input with attributes --&gt;
      &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  <p>I get an error as the form status is unknown</p>