Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DomCrawler] Added support for 'link' tags in the Link class #12487

Closed
wants to merge 1 commit into from

Conversation

stephaneseng
Copy link
Contributor

Q A
Bug fix? No
New feature? Not really
BC breaks? No
Deprecations? No
Tests pass? Yes (at least those of DomCrawler)
Fixed tickets N/A
License MIT
Doc PR N/A

My use case is that I crawl web pages for RSS links so I need to retrieve the 'href' attributes of 'link' elements.
I would like to use the Link class to resolve encountered 'href' relative URLs.

Please note that I did not replace if ('a' !== $node->nodeName && 'area' !== $node->nodeName) with if (!$node->hasAttribute('href')) to ensure backward compatibility.
Indeed, according to http://www.w3.org/TR/html5/links.html, the 'href' attribute is optional for 'a' and 'area' elements.

@stephaneseng
Copy link
Contributor Author

Below is the failed test output.
There might have been a network error during the test execution.

Running src/Symfony/Component/Filesystem tests
Loading composer repositories with package information
Installing dependencies (including require-dev)
Nothing to install or update
Generating autoload files
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /home/travis/build/symfony/symfony/src/Symfony/Component/Filesystem/phpunit.xml.dist
............E.................................................... 65 / 97 ( 67%)
................................
Time: 540 ms, Memory: 6.00Mb
There was 1 error:
1) Symfony\Component\Filesystem\Tests\FilesystemTest::testCopyForOriginUrlsAndExistingLocalFileDefaultsToNotCopy
Symfony\Component\Filesystem\Exception\IOException: Failed to copy "http://symfony.com/images/common/logo/logo_symfony_header.png" to "/tmp/141606272844/copy_target_file" because source file could not be opened for reading.
/home/travis/build/symfony/symfony/src/Symfony/Component/Filesystem/Filesystem.php:55
/home/travis/build/symfony/symfony/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php:179

FAILURES!                             
Tests: 97, Assertions: 151, Errors: 1.

@fabpot
Copy link
Member

fabpot commented Nov 16, 2014

Thank you @stephaneseng.

fabpot added a commit that referenced this pull request Nov 16, 2014
…ss (StephaneSeng)

This PR was submitted for the master branch but it was merged into the 2.6 branch instead (closes #12487).

Discussion
----------

[DomCrawler] Added support for 'link' tags in the Link class

| Q             | A
| ------------- | ---
| Bug fix?      | No
| New feature?  | Not really
| BC breaks?    | No
| Deprecations? | No
| Tests pass?   | Yes (at least those of DomCrawler)
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

My use case is that I crawl web pages for RSS links so I need to retrieve the 'href' attributes of 'link' elements.
I would like to use the Link class to resolve encountered 'href' relative URLs.

Please note that I did not replace `if ('a' !== $node->nodeName && 'area' !== $node->nodeName)` with `if (!$node->hasAttribute('href'))` to ensure backward compatibility.
Indeed, according to http://www.w3.org/TR/html5/links.html, the 'href' attribute is optional for 'a' and 'area' elements.

Commits
-------

d8d6fcf [DomCrawler] Added support for link tags in the Link class
@fabpot fabpot closed this Nov 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants