0

enter image description hereTrying to make a double curl in the first curl we are accepting the message by posting the form to the same page. After that we should be posting another curl with the cookies but for some reason the page is not remembering the old CURL.

I have tried 2 different methods and both don't seem to be working and doing the thing I want them to do. Can someone please tell me how I can get the first CURL page to post to the second one without going back to the message part.

The code is as following:

<?php

// Retrieving session ID 
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';    
// create both cURL resources
$ch1 = curl_init();

  $fields = array( 'akkoord'=>'Verder', 'accept'=>'true');
  $fields2 = array('akkoord'=>'Verder', 'accept'=>'true', ''=>'Watermolen 21 Edam');

  $postvars = '';
  foreach($fields as $key=>$value) {
    $postvars .= $key . "=" . $value . "&";
  }
  $postvars2 = '';
  foreach($fields2 as $key2=>$value2) {
    $postvars2 .= $key2 . "=" . $value2 . "&";
  }
// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "https://www.wozwaardeloket.nl/index.jsp");
curl_setopt($ch1, CURLOPT_COOKIEJAR, '/cookies.txt');
curl_setopt($ch1, CURLOPT_COOKIEFILE, '/cookies.txt');
curl_setopt($ch1, CURLOPT_COOKIE, $strCookie ); 
curl_setopt($ch1, CURLOPT_POSTFIELDS, $postvars); 


$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, "https://www.wozwaardeloket.nl/index.jsp");
curl_setopt($ch2, CURLOPT_COOKIEJAR, '/cookies.txt');
curl_setopt($ch2, CURLOPT_COOKIEFILE, '/cookies.txt');
curl_setopt( $ch2, CURLOPT_COOKIE, $strCookie ); 
 curl_setopt($ch2, CURLOPT_POSTFIELDS, $postvars2); 


//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$active = null;
//execute the handles
do {
    $mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}

//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);
?>

Thanks in advance!

Both Scripts The message that shows up before scrambling

BartMolk
  • 37
  • 6
  • _“accepting the message by posting the form to the same page”_ - what does that _mean_? Are you making cURL request to your _own_ system? And if so, why, what is the purpose of that? – CBroe Mar 04 '21 at 13:28
  • I am trying to make a CURL from my website www.website.nl to www.wozwaardeloket.nl the message I am talking about is some sort of "Acceptance" popup before you start searching for an adres. Then from www.wozwaardeloket.nl it should post another time when it has accepted the message to the same page wozwaardeloket.nl – BartMolk Mar 04 '21 at 13:51
  • Then what is the purpose of passing your site’s session id, to the other site? Are they sharing the session somehow, or - what? – CBroe Mar 04 '21 at 14:08
  • And the point of send a parameter without any name is also unclear, `''=>'Watermolen 21 Edam'` – CBroe Mar 04 '21 at 14:09
  • I added the session to make it rember the cookie and maybe some way keep the curls connected. The input is empty and has no name on wozwaardeloket.nl and I am trying to get the prices if you add an adres. If you test the website you can check what I am trying to tell your, Search on the 'Watermolen 21 Edam' string on the website after accepting the message. It will show you a lists of what your house is worth based on dutch statistics. Is it actually possible to make 2 CURL calls consisting the same cookie / user data and hiding the message the second CURL call? – BartMolk Mar 04 '21 at 14:26
  • But what is the other site supposed to do with _your_ session id? This doesn’t make sense. – CBroe Mar 04 '21 at 15:07
  • The first thing that happens, after I input `Watermolen 21 Edam` into the search box, is a couple of AJAX requests … so most likely, you won’t be able to replicate the functionality with just a couple of basic cURL requests anyway. You are going to need a _headless browser_, if you want to scrape contents that are loaded via client-side scripting. – CBroe Mar 04 '21 at 15:11
  • Thanks for your reply, that was already what I was thinking since I took a look at the javascript files and saw 2 different calls being made for the data... Means I have to dive into python and educate myself more than, was already learning it this week tho!! Thanks for your advice and help mate! – BartMolk Mar 04 '21 at 17:52

0 Answers0