I'm using https://github.com/dweidner/laravel-goutte crawler and trying to login to https://home.openweathermap.org/users/sign_in but response I'm getting is only:
Error message:
The change you wanted was rejected.
Maybe you tried to change something you didn't have access to.
If you are the application owner check the logs for more information.
Code:
$client = new Client();
$crawler = $client->request('GET', 'https://home.openweathermap.org/users/sign_in');
$form = $crawler->filter('#new_user')->form();
$crawler = $client->submit($form, array('user[email]' => 'email', 'user[password]' => 'password'));
echo $crawler->html();
Is it possible to login and scrape openweathermap page? If so how could I do that?
Thank you for your help.
Fix for this problem:
$client = new Client();
$crawler = $client->request('GET', 'https://home.openweathermap.org/users/sign_in');
$form = $crawler->filter('#new_user')->form();
$token = $crawler->filter('meta[name="csrf-token"]')->first()->attr('content');
$crawler = $client->submit($form, [
'user[email]' => 'email',
'user[password]' => 'password',
'authenticity_token' => $token]);
echo $crawler->html();