@@ -370,28 +370,26 @@ This behavior is best illustrated with examples::
370370Links
371371~~~~~
372372
373- To find a link by its ``id `` or its ``class `` attribute(s), use the ``filter() ``
374- method on an existing crawler. To find a link by name (or a clickable image by
375- its ``alt `` attribute), use the ``selectLink() `` method on an existing crawler.
376- This returns a ``Crawler `` instance with just the selected link(s). Calling
377- ``link() `` gives you a special :class: `Symfony\\ Component\\ DomCrawler\\ Link ` object::
378-
379- // select the link by its id
380- $linksByIdCrawler = $crawler->filter('#your-link');
381- $link = $linksByIdCrawler->link();
382-
383- // select the link by its class
384- $linksByClassCrawler = $crawler->filter('.link');
385- $link = $linksByClassCrawler->link();
386-
387- // select the link by its name
388- $linksByNameCrawler = $crawler->selectLink('Go elsewhere...');
389- $linkByName = $linksCrawler->link();
390-
391- // or do this all at once
392- $linkById = $crawler->filter('#your-link')->link();
393- $linkByClass = $crawler->filter('.link')->link();
394- $linkByName = $crawler->selectLink('Go elsewhere...')->link();
373+ Use the ``filter() `` method to find links by their ``id `` or ``class ``
374+ attributes and use the ``selectLink() `` method to find links by their content
375+ (it also finds clickable images with that content in its ``alt `` attribute).
376+
377+ Both methods return a ``Crawler `` instance with just the selected link. Use the
378+ ``link() `` method to get the :class: `Symfony\\ Component\\ DomCrawler\\ Link ` object
379+ that represents the link::
380+
381+ // first, select the link by id, class or content...
382+ $linkCrawler = $crawler->filter('#sign-up');
383+ $linkCrawler = $crawler->filter('.user-profile');
384+ $linkCrawler = $crawler->selectLink('Log in');
385+
386+ // ...then, get the Link object:
387+ $link = $linkCrawler->link();
388+
389+ // or do all this at once:
390+ $link = $crawler->filter('#sign-up')->link();
391+ $link = $crawler->filter('.user-profile')->link();
392+ $link = $crawler->selectLink('Log in')->link();
395393
396394The :class: `Symfony\\ Component\\ DomCrawler\\ Link ` object has several useful
397395methods to get more information about the selected link itself::
0 commit comments