user1581663
user1581663

Reputation:

Symfony2 DomCrawler Link

I'm using Symfony2 DOMCrawler. I have a link on page. I want to go thru the link and crawl some content there. How can I do it? LEt the code be like this

<a href="www.example.com">Go there</a>

I know about $crawler->selectLink('Go there')->link();

Upvotes: 4

Views: 11060

Answers (2)

Babou34090
Babou34090

Reputation: 381

Maybe you are looking for something like :

$link = $crawler->filter('a[id="fabulous_id"]')->attr('href');
$crawler = $client->request('GET',$link);

look DomCrawler Doc for informations

Upvotes: 11

Vitalii Zurian
Vitalii Zurian

Reputation: 17976

You are looking for click() method.

$link = $crawler->selectLink('Go there')->link();
$crawler = $client->click($link);

You should read this documentation chapter more careful

Upvotes: 6

Related Questions