On Amazon Create Wish List Link which popup a form. the form contains a submit button in following fashion:
<span class="a-button-inner"><input data-action="reg-create-submit" data-reg-create-submit="{"sid":"192-7611799-5529931"}" class="a-button-input a-declarative" type="submit" aria-labelledby="a-autoid-162-announce"><span class="a-button-text" aria-hidden="true" id="a-autoid-162-announce">
Create a Wish List
</span></span>
I am using following code but it is not fetching form:
require_once 'goutte.phar';
error_reporting(E_ALL);
use Goutte\Client;
$crawler = $client->request('GET',$url);
$status_code = $client->getResponse()->getStatus();
$form = $crawler->selectButton('Sign in')->form();
$crawler = $client->submit($form, array('email' => '[email protected]', 'password' => 'amazonpasswd'));
//Create a Wish List
$crawler = $client->request('GET',"http://www.amazon.com/gp/registry/wishlist/ref=nav_wishlist_create?ie=UTF8&triggerElementID=createList");
sleep(5);
$form = $crawler->selectButton('
Create a Wish List
')->form();
print_r($form); //It returns Nothing
The issue is probably that selectButton()
matches exact text which in my case is not there. Please help
Well let's get this straight. What you need is to reach your target "form" element, for this matter, you don't strictly need to use the "selectButton" function you can get this element with just an XPath expression.
I think the web structure has changed since you posted this, because now the "Create a Wish List" button apparently has a value "createNew" but in order to crawl websites with a button with no value you can do this:
That way you can access a form without the selectButton function and you can input that form the normal way:
Hope this helps.