How to use cURL form values ​​for POST in a form using JS

* Sorry for the long post * I use cURL in PHP for postsome form fields to return the result I postneed help because the form is somewhat unusual.

cURL Script

 $ch = curl_init();
 $data = array('field_1_name' => 'field_value',
               'field_2_name' => 'field_value',
               'field_3_name' => 'field_value',
              ); 
 curl_setopt($ch, CURLOPT_URL,'http://url.com');  
 curl_setopt ($ch, CURLOPT_POST, 1);
 curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 $fp = fopen('data.php', 'w');
 curl_setopt($ch, CURLOPT_FILE, $fp);
 curl_exec ($ch);
 curl_close ($ch);
 fclose($fp);

Things You Should Know About

  • Fields are not text-fields, but are a combination of radioand dropdown.
  • The form contains JS, but the firebug console does not show AJAXmessages - instead, the form works with SESSIONSand HTTP-CACHE.
  • Once the form field is selected, the page looks like reloadand the values ​​of the next drop-down list are inserted. (Again firebug does not show this as a request AJAX.)

Here is an example of a field dropdownin the form

<select name="field_name" onchange="document.getElementById('uploadForm').action.value='RELOAD';document.getElementById('uploadForm').reloadTrigger.value='trigSize';document.getElementById('uploadForm').submit();">
   <option value="option_1">option_1</option>
   <option value="option_2">option_2</option>
   <option value="option_3">option_3</option>
</select>

onChange, dropdwon options.

,

dropdown . , , , . , .

, :

option_1   |   option_2   |   option_3   |   price   |
field_1    |   field_2    |   field_3    |    25     |

, - ( : toots/libraries/tutorials/etc.) , cURL . PHP. , ? . .

- - script RUBY, WATIR-WebDriver, , . 5000 , 10 . ()

1

. . , .

0
1

, , HTML-. . , , . . .

, .

0

Source: https://habr.com/ru/post/1778297/


All Articles