Goutte
Goutte copied to clipboard
Setting user-agent not working
Hello,
we've got the problem that setting the user-agent will end up in "You use an unknown device or you are in privacy mode", so we can not access some websites. Do you have a solution for this?
require('vendor/autoload.php');
set_time_limit('0');
error_reporting(E_ALL);
/*
$client = new \Goutte\Client([
]);*/
$driver = new \Behat\Mink\Driver\GoutteDriver();
$session = new \Behat\Mink\Session($driver);
// start the session
$session->start();
$session->visit('URL');
$page = $session->getPage();
$loginForm = $page->findById('loginForm');
$loginFormUsername = $loginForm->findField('userName');
if (null === $loginFormUsername) {
throw new \Exception('The element is not found');
} else {
$loginFormUsername->setValue('USERNAME');
}
$loginFormPassword = $loginForm->findField('password');
if (null === $loginFormPassword) {
throw new \Exception('The element is not found');
} else {
$loginFormPassword->setValue('PASSWD');
}
$loginForm->submit();
print_r($loginForm);
Some suggestions?
Have you tried using a your own guzzle instance that has a custom user agent defined?