Я очищаю сайт, чтобы получить некоторые данные, и мне нужно время, поэтому я погуглил и обнаружил, что очередь хороша для этого процесса. Я застрял в этой ошибке.
Serialization of 'Closure' is not allowed
Мой код:
class SiteScraper extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
protected $client;
protected $crawler;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
$this->client = new Client();
$this->crawler = $this->client->request('GET', 'example.com/login/');
$form = $this->crawler->selectButton('Log In')->form();
$this->crawler = $this->client->submit($form, array('email' => 'useremail', 'pass' => 'pass'));
$this->crawler->filter('.flash-error')->each(function ($node) {
print $node->text() . "\n";
});
}
public function handle()
{
$crawler = $this->client->request('GET', $url_to_traverse);
$status_code = $this->client->getResponse()->getStatus();
if($status_code == 200){
$crawler->filter('.friendBrowserNameTitle > a')->each(function ($node) {
$names = $node->text() . '<br>';
$profileurl = $node->attr('href') . '<br>';
echo "Name : " . $names . " Profile Link : " . $profileurl;
});
}
else{
echo $status_code;
}
}
}
Любая помощь, где я ошибаюсь?