fubowl Posted September 16, 2006 Share Posted September 16, 2006 I am trying to submit a form to get specific results. The problem is that the server I'm trying to get it from using a session cookie to log the result and then destroys it. I've been trying to get a result using cURL but am unsure of how to go about it. I have the search form but cannot follow it using cURL. However, I am more interested in getting the results.Can you set cURL to follow a submitted form?If not, how can you go about showing results in such a circumstance.I know you can go about pre-filling CURLOPT_POSTFIELDS but I have not had success in doing so, or is there an easier way?I would really appreciate a working example, everything I've tried to this point has failed. Link to comment https://forums.phpfreaks.com/topic/20968-curl-question/ Share on other sites More sharing options...
ronverdonk Posted September 16, 2006 Share Posted September 16, 2006 I am just a curl beginner, but I think you have to use the CURLOPT_RETURNTRANSFER option. See form more info on this the PHPit article at [url=http://www.phpit.net/article/using-curl-php/]http://www.phpit.net/article/using-curl-php/[/url]Ronald 8) Link to comment https://forums.phpfreaks.com/topic/20968-curl-question/#findComment-92971 Share on other sites More sharing options...
michaellunsford Posted September 16, 2006 Share Posted September 16, 2006 Here's what I'm using to do the same thing... It uses postfields, followlocation, and a cookiejar. You just string the post fields together like you would using the GET method -- but curl will POST them instead.[code=php:0]if(file_exists("my_cookies.txt")) unlink("my_cookies.txt");$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.example.com/someform.php");curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, "userid=".$user[0]."&password=".$user[1]);curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412.6 (KHTML, like Gecko) Safari/412.2");curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $var=curl_exec($ch); [/code] Link to comment https://forums.phpfreaks.com/topic/20968-curl-question/#findComment-93081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.