cURL / Mailing Lists / curl-users / Single Mail

curl-users

Problems downloading aspx pages with curl ( cont )

From: Bob Steinberg <bobs_at_computilizer.com>
Date: Sun, 12 Dec 2004 21:38:39 -0500

Hit <ctrl><enter> instead of enter. duhh.

anyhow, the preliminary post did not request any search results, just opened
the index
page to gather teh cookie and that state looking variable.

the rest of the parameters and valid answers are directly from a view source
of the
form on the index page.

here is the function being used to post the form

--- start code ---
function http_transaction( $url, $params, $cookie="", $ch=0, $user="",
$pass="", $header="", $method='POST', $user_agent= "Mozilla/4.0 (compatible;
MSIE 6.0; Windows 98)", $HTTP_REFERER="http://www.pool.com" ) {
 $Debug=true;

 if ( $ch==0 ) $ch = curl_init(trim($url));
 if ( $Debug ) print "CH: $ch<br>\n";

 curl_setopt($ch, CURLOPT_TIMEOUT, 0 );
 curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 0 );
 curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, 100000 );

 curl_setopt($ch, CURLOPT_VERBOSE,1);
 curl_setopt($ch, CURLOPT_HEADER,1);
 curl_setopt($ch, CURLOPT_REFERER,$HTTP_REFERER);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 if ( $Debug ) print "REFERER: $HTTP_REFERER<br>\n";
 if ( $cookie!="" ) {
  curl_setopt($ch, CURLOPT_COOKIE, $cookie );
  if ( $Debug ) print "COOKIE: $cookie<br>\n";
  }

 if ( $method=='GET' ) {
  $url.=$params;
  curl_setopt($ch, CURLOPT_POST,0);
  curl_setopt($ch, CURLOPT_POSTFIELDS,"");
  }
 else {
  curl_setopt($ch, CURLOPT_POST,1);
  curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
  }

 // curl_setopt($ch, CURLOPT_URL,trim($url));

 if ( $Debug ) print "URL: $url<br>\n";
 if ( $Debug ) print "PARAM: $params<br>\n";
 if ( $Debug ) print "METHOD: $method<br>\n";
 if ( $Debug ) print "USERAGENT: $user_agent<br>\n";

 // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
 // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // this line makes it
work under https

 curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
 // curl_setopt($ch, CURLOPT_NOPROGRESS,1 );

 // curl_setopt($ch, CURLOPT_RANGE,"1-100000" );
 // curl_setopt($ch, CURLOPT_READFUNCTION, "read_callback" );

 curl_setopt($ch, CURLOPT_COOKIEJAR, "cook");
 curl_setopt($ch, CURLOPT_COOKIEFILE, "cook");

 if ( $header!="" ) curl_setopt ($ch, CURLOPT_HTTPHEADER, $header );
 if ( $user!="" ) curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass" );
 if ( $Debug ) print "<pre>Header: ".print_r( $header )."<pre><br>\n";

 flush();

 $result=curl_exec ($ch);

 if ( $Debug ) print "Error: ( ".curl_errno ( $ch )." )".curl_error (
$ch )."<br>\n";

 curl_close($ch);

 if ( $Debug ) print "Results: <br>".$result;

 $Return["ch"]=$ch;
 $Return["page"]=$result;

 return( $Return );
 }

--- end code ---

any help will be greatly appreciated
Received on 2004-12-13