0

Curl Info shows its successful :

array(37) { ["url"]=> string(50) "http://abcd.bd/abcd.php" ["content_type"]=> string(24) "text/html; charset=UTF-8" ["http_code"]=> int(200) ["header_size"]=> int(318) ["request_size"]=> int(403) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(2.218) ["namelookup_time"]=> float(1.0E-6) ["connect_time"]=> float(0.078) ["pretransfer_time"]=> float(0.078) ["size_upload"]=> float(637) ["size_download"]=> float(5878) ["speed_download"]=> float(2650) ["speed_upload"]=> float(287) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(637) ["starttransfer_time"]=> float(0.078) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) ""  ["certinfo"]=> array(0) { } ["primary_port"]=> int(80) ["local_ip"]=> string(13) "10.102.11.131" ["local_port"]=> int(54537) ["http_version"]=> int(2) ["protocol"]=> int(1) ["ssl_verifyresult"]=> int(0) ["scheme"]=> string(4) "HTTP" ["appconnect_time_us"]=> int(0) ["connect_time_us"]=> int(78000) ["namelookup_time_us"]=> int(1) ["pretransfer_time_us"]=> int(78000) ["redirect_time_us"]=> int(0) ["starttransfer_time_us"]=> int(78000) ["total_time_us"]=> int(2218000) } 

but my curl_exec($ch) returns only header and footer. Table data is not showing up.

I have tried all the option but still no luck .

curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_REFERER, $url_register.'a.php');
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_URL, $url_register.'a.php');
curl_setopt ($ch, CURLOPT_POST, 1); 
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Accept: text/html; charset=UTF-8'));

$result = curl_exec($ch);

FYI The response page I want contain

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

at top.

I dont know whats wrong . It should be simple. what i am missing here???

Barmar
  • 741,623
  • 53
  • 500
  • 612
Insanity Geek
  • 157
  • 1
  • 12
  • Does it really contain `"<'`? That's not valid HTML. Or did you add that quote to keep SO from interpreting what you wrote as HTML? The best way to do that is to put the output into a code block. – Barmar Mar 10 '19 at 11:03
  • Do you have `echo $result;`? Have you used `View Source` to see what it's actually echoing? – Barmar Mar 10 '19 at 11:05
  • Maybe the page uses JavaScript to fill in the table data. `curl` doesn't execute JS. – Barmar Mar 10 '19 at 11:07
  • @Barmar any solution for this?? If it is JS? – Insanity Geek Mar 10 '19 at 11:17
  • https://stackoverflow.com/questions/199045/is-there-a-php-equivalent-of-perls-wwwmechanize – Barmar Mar 10 '19 at 11:18
  • I have tried echo $result , var_dump and view source . And Found no table data. – Insanity Geek Mar 10 '19 at 11:18
  • https://stackoverflow.com/questions/29726340/php-curl-a-page-apply-javascript-and-save-result – Barmar Mar 10 '19 at 11:18
  • Do you see JavaScript that's performing AJAX calls to get the table data? – Barmar Mar 10 '19 at 11:19
  • @Barmar Please check this fiddle. http://jsfiddle.net/x3qp519h/ – Insanity Geek Mar 10 '19 at 11:21
  • If it's using AJAX, you can just see what URL it's sending the AJAX request to, and use `curl` to make the same queries in your script. – Barmar Mar 10 '19 at 11:21
  • @Barmar I just put all the information in JS. Just submit and see the page. – Insanity Geek Mar 10 '19 at 11:22
  • I don't understand what that fiddle is supposed to do. There's no form to submit. – Barmar Mar 10 '19 at 11:23
  • Browse the link and submit the data. – Insanity Geek Mar 10 '19 at 11:25
  • Are you filling in the `value_s` field of the form correctly when you send the curl request? It's a CAPTCHA that requires you to read the equation in the previous column and fill in the result. So if it says `7 + 9` you have to put `16` in that field. – Barmar Mar 10 '19 at 11:29
  • Yes. I did and got 200 response . Thats not a problem . I got response of the desired page except the table data. – Insanity Geek Mar 10 '19 at 11:30
  • 1
    There's no JavaScript in the response page, so that's not the problem. Are you sure you're sending the correct cookie data? You have to first download the form to get the cookies, then submit the form with the same cookies. – Barmar Mar 10 '19 at 11:38
  • That could be a problem , coz I'm using curl_setopt($ch, CURLOPT_COOKIEJAR, 1); – Insanity Geek Mar 10 '19 at 11:40
  • 1
    You should use `curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);` just like when you're submitting the form. – Barmar Mar 10 '19 at 11:42
  • $cookie should be an empty text file right?? – Insanity Geek Mar 10 '19 at 11:50
  • Right, it will be filled in when you make requests that send back cookies. – Barmar Mar 10 '19 at 11:52
  • can you show me a link . I dont know How to filled in? Filled with what data?? I am trying this : $cookie = 'PHPSESSID=' . session_name() . '; path=/'; – Insanity Geek Mar 10 '19 at 11:55
  • `$cookie` contains a filename. `CURLOPT_COOKIEJAR` means that it should save the returned cookies there, and `CURLOPT_COOKIEFILE` means it should send the cookies from the file. – Barmar Mar 10 '19 at 11:57
  • You don't fill it in at all. When you request `index.php` it fills it in, and then when you submit the form it sends the cookies back. – Barmar Mar 10 '19 at 11:58
  • It's just like using cookies to login to a web site. See https://stackoverflow.com/questions/20049393/using-php-curl-to-login-to-my-websites-form for examples. – Barmar Mar 10 '19 at 12:03
  • @Barmar its not working . check my full code : https://pastebin.com/WYWkP6yW – Insanity Geek Mar 11 '19 at 03:41

0 Answers0