0

I use Goutte scraper package in php.

I want to manually solve the captcha while scraping. I am able to detect a catpcha picture. I also created a form to write captcha value and pass it to the scraper but the problem is that when I enter the captcha value it resets the scraper and a new captcha is provided.

I need to pause the scraper, enter the captcha value manually and use this value to resume the scraping.

How can I do this?

$client=new client();

$crawler=$client->request('GET','http://example.com');

$form = $crawler->selectButton('submit form')->form();
$src=$crawler->filter('#td_captcha img')->extract(array('src'));

echo '<img src="'.$src[0].'">';

//I need to pause scrapper here

echo '
<form  method="post" >

  <input type="text"  name="captcha" value="">      
  
  <input type="submit" value="captcha" name="submit">
</form>';

// after entering captcha value manually, resume the scrapper
if(isset($_POST['captcha'])){
    $captcha=$_POST['captcha'];
    $crawler = $client->submit($form, ['st_fname' => 'a', 'st_lname' => 'a', 'st_father' => 'a', 'st_iid' => 'a', 'st_nid' => '111', 'captcha' =>  $captcha]);

}

I searched the web but I didn't find a solution.

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
aminjabari
  • 21
  • 3

0 Answers0