Last active
August 29, 2015 14:06
-
-
Save giorrrgio/37d9c9b4d7f2ef7889c3 to your computer and use it in GitHub Desktop.
HtmlScraper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"symfony/dom-crawler": "*", | |
"symfony/css-selector": "*" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'vendor/autoload.php'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\DomCrawler\Crawler; | |
require_once 'vendor/autoload.php'; | |
$html = '<html><body><p>Hello World!</p></body></html>'; | |
$crawler = new Crawler($html); | |
var_dump($crawler->html()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\DomCrawler\Crawler; | |
require_once 'vendor/autoload.php'; | |
$url = 'http://en.wikipedia.org/wiki/Flying_Spaghetti_Monster'; | |
$html = file_get_contents($url); | |
$crawler = new Crawler($html); | |
$history = $crawler | |
->filter('h2:contains("History") + p'); | |
var_dump($history->html()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment