title: Screen Scraping of aspx page using curl
body: <p>I am using this code, and its not working. Please help</p>
  
  <pre><code>$url = "http://www.riogrande.com/Category/Findings-and-Finished-Jewelry/132/Bails-and-Enhancers/472";
  $file=file_get_contents($url);
  preg_match("#.*?#mis", $file, $arr_viewstate);
  $viewstate = urlencode($arr_viewstate[1]);
  $eventvalidation = urlencode($arr_viewstate[2]);
  $options = array(
      CURLOPT_RETURNTRANSFER =&gt; true, // return web page
      CURLOPT_HEADER =&gt; false, // don't return headers
      CURLOPT_ENCODING =&gt; "", // handle all encodings
      CURLOPT_USERAGENT =&gt; "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7'", // who am i
      CURLOPT_AUTOREFERER =&gt; true, // set referer on redirect
      CURLOPT_CONNECTTIMEOUT =&gt; 120, // timeout on connect
      CURLOPT_TIMEOUT =&gt; 1120, // timeout on response
      CURLOPT_MAXREDIRS =&gt; 10, // stop after 10 redirects
      CURLOPT_POST =&gt; true,
      CURLOPT_VERBOSE =&gt; true,
      CURLOPT_POSTFIELDS =&gt; '__EVENTTARGET='.urlencode('ctl00$ContentPlaceHolderBody$SearchPageNavigationTop$rptPager$ctl01').'&amp;__EVENTARGUMENT='.urlencode('').'&amp;__VIEWSTATE='.$viewstate.'&amp;__EVENTVALIDATION='.$eventvalidation.'&amp;__LASTFOCUS='.urlencode('')
  );
  
  $ch = curl_init($url);
  curl_setopt_array($ch,$options);
  </code></pre>