title: How can I programmatically scrape a web page and "click" a javascript button?
body: <p>I'm trying to scrape a web page for work where there are hundreds of table rows with a check box, and to submit the form I need to click a button which calls a javascript function. The button in html looks like this:</p>
  
  <pre><code>&lt;a onclick="JavaScript: return verifyChecked('Resend the selected request for various approvals?');"
  id="_ctl0_cphMain_lbtnReapprove"
  title="Click a single request to send to relevant managers for reapproval."
  class="lnkDBD" href="javascript:__doPostBack('_ctl0$cphMain$lbtnReapprove','')"
  style="border-color:#0077D4;border-width:1px;border-style:Solid;text-decoration: overline;"&gt;&amp;nbsp;Resend&amp;nbsp;&lt;/a&gt;
  </code></pre>
  
  <p>I know with libraries like beautiful soup you can submit forms by adding post data to the url, but how could I check a checkbox and "click" this javascript button? The website is a help desk of sorts, and for this particular button we can only check one request at a time which takes way too long when there are hundreds of requests that need re-submitted.</p>
  
  <p>When I check the checkbox a message also pops up verifying that I want to do this, I don't know if that will affect programmatically submit it.</p>
  
  <p>EDIT: I forgot to include the doPostBack method.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  &lt;!--
  var theForm = document.forms['aspnetForm'];
  if (!theForm) {
      theForm = document.aspnetForm;
  }
  function __doPostBack(eventTarget, eventArgument) {
      if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
          theForm.__EVENTTARGET.value = eventTarget;
          theForm.__EVENTARGUMENT.value = eventArgument;
          theForm.submit();
      }
  }
  // --&gt;
  &lt;/script&gt;
  </code></pre>