Why doesn't Guzzle POST request to fill a third party form?

0 like 0 dislike
5 views
The library has a search form books. But initially the page has no tag and InputB with the desired name.
5ae7013230135461721418.png
The user writes the title of the book and presses the button. As I understand it, then the script runs that reads the data filled in forms with them in the present form and sends by POST.
5ae70160e1bf9353311085.png
Without reloading the page, the user receives search result:
5ae7042f6dcbf777505505.png

I need to programmatically fill in this form and display the result page. Analyze using the panel Network which data is sent, repeat the request with such parameters, but does not work.

require 'vendor/autoload.php'; // Connect the Client class use GuzzleHttp\\Client; // Initialize a class to work with remote web resources $client = new Client(); // Do query, get response $response = $client->request("POST", "http://opac.rgub.ru/cgiopac/opacg/opac.exe", [ "form_params" => [ "arg0" => "GUEST", "arg1" => "GUESTE", "TypeAccess" => "FreeAccess", "_errorXsl" => "/opacg/html/common/xsl/error.xsl", "_wait" => "6M", "_xsl" => "/opacg/html/search/xsl/search_results.xsl", "_version" => "2.0.0", The "_service" => "STORAGE:opacfindd:FindView", "outform" => "SHOTFORM", "length" => "15", "query/body" => "%28TI+%CE%E1%EB%EE%EC%EE%E2%29", "query/open" => "{NC:}", "query/close" => "{NC:}", "userId" => "GUEST", "session" => "495180", "iddb" => "5", "level[0]" => "Full", "level[1]" => "Retro" ] ]); // Output the response echo $response->getBody();


What is missing?

UPD
Not enough data transferred from opac.rgub.ru/opacg/guest.html in opac.rgub.ru/cgiopac/opacg/opac.exe:
"arg0" => "GUEST", "arg1" => "GUESTE", "TypeAccess" => "FreeAccess"

Better. Instead of "Not enough input data. Go back to the search." is displayed with khtml, but on the page nothing is displayed.

Trying to put the title of the first book in the results, nothing is displayed.
// Find the desired of HTML issuance $htmlRGBM = $response->getBody(); $docRGBM = new DOMDocument(); @$docRGBM->loadHTML($htmlRGBM); $xpathRGBM = new DOMXpath($docRGBM); echo $xpathRGBM->query('//entry[1]/text()')[0]->nodeValue;
by | 5 views

1 Answer

0 like 0 dislike
Look in the development tools which flies the request to the server.
The first thing to notice is the parameter encoding the query/body using urlencode.
Further poprobuite to shoot the headers: referer and user-agent though.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,701 users