ijortengab/browser

HTTP Requester like a browser, automatically save and load cookie, follow location, and save the history and cache.

v0.0.9 2016-01-17 16:16 UTC

This package is not auto-updated.

Last update: 2024-05-21 02:27:54 UTC


README

HTTP Requester like a browser, automatically save and load cookie, follow location, and save the history and cache.

Requirement:

// Simple request.
$browser = Browser::profile('Mozilla Firefox on Windows 7');
$browser->setUrl('http://httpbin.org/html')->execute();
$html = (string) $browser->result;
// Post request, login, and enter to authenticated page.
$browser = Browser::profile('Mobile');
$browser->setUrl('http://httpbin.org/post');
$browser->post([
    'username' => 'IwanFals',
    'password' => 'SoreTuguPancoran',
]);
$browser->headers('Referer', 'http://httpbin.org/');
$browser->options('timeout', 5);
$browser->execute();
// Cookie automatically saved.
$browser->reset()->setUrl('http://httpbin.org/member-area-only')->execute();
// Cookie automatically loaded, and with session information in cookie
// you can enter page which is for authenticated only.
$code = $browser->result->code; // 200 OK.
$html = $browser->result->data;