Goutte icon indicating copy to clipboard operation
Goutte copied to clipboard

Setting user-agent not working

Open jonyking opened this issue 3 years ago • 2 comments

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);

jonyking avatar Aug 09 '21 15:08 jonyking

Some suggestions?

jonyking avatar Aug 10 '21 10:08 jonyking

Have you tried using a your own guzzle instance that has a custom user agent defined?

georaldc avatar Aug 20 '21 16:08 georaldc