title: Getting value from hidden form with BeautifulSoup
body: <p>I'm trying to scrape a website which has the following in its HTML</p>
  
  <pre><code>&lt;form id="__AjaxAntiForgeryForm" action="#" method="post"&gt;
     &lt;input name="__RequestVerificationToken" type="hidden" value="LOUesP09TLS3suKJk4dF5hIxeo-LmDWLxX8xqwIHYnj-JqR29qDcGA_mtHXvyZIej83qG3FfBBs2nuzk1EY6onTuszY1"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and I'm trying to extract the <code>value</code> with BeautifulSoup using</p>
  
  <pre><code>page = urllib2.urlopen(LOGIN_URL)
  # parse the html using beautiful soup and store in variable `soup`
  soup = BeautifulSoup(page, "html.parser")
  
  form = soup.find("form", {"id": "__AjaxAntiForgeryForm"})
  </code></pre>
  
  <p>which correctly returns</p>
  
  <pre><code>&lt;form action="#" id="__AjaxAntiForgeryForm" method="post"&gt;&lt;input name="__RequestVerificationToken" type="hidden" value="zd7XHXyVs7EgqObLzIfm9k4bw1cWfcddhfDZ9Mp8TibBaAJUz-yAp1ZBuKS1iJtEAvmI1WG_EYnbmXBnWzuKWJxfl8U1"/&gt;&lt;/form&gt;
  </code></pre>
  
  <p>My problem is in extracting just the value from that tag. </p>
  
  <p>I've tried <a href="https://stackoverflow.com/questions/23001678/python-beautiful-soup-form-input-parsing">this</a> answer and using</p>
  
  <pre><code>form = soup.find("form", {"id": "__AjaxAntiForgeryForm"})['value']
  </code></pre>
  
  <p>based on <a href="https://stackoverflow.com/questions/46028156/python-beautiful-soup-getting-input-value?rq=1">this</a> answer but it just returns <code>KeyError: 'value'</code>. </p>
  
  <p>I could convert it to a string and use regex to extract the value but that seems clunky and there must be a cleaner way of doing it using BeautifulSoup.</p>
  
  <p>Any ideas?</p>