Skip to content

Instantly share code, notes, and snippets.

@apperceive
Created October 4, 2015 13:54
Show Gist options
  • Save apperceive/cd130ea479fd6fca7ae4 to your computer and use it in GitHub Desktop.
Save apperceive/cd130ea479fd6fca7ae4 to your computer and use it in GitHub Desktop.
Simple example to dump all selectors using Sabberworm CSS parser
<?php
require_once(dirname(__FILE__).'/bootstrap.php');
$oParser = new Sabberworm\CSS\Parser(file_get_contents('php://stdin'));
$oCss = $oParser->parse();
foreach($oCss->getAllDeclarationBlocks() as $oBlock) {
foreach($oBlock->getSelectors() as $oSelector) {
print $oSelector->getSelector() . "\n";
}
}
?>
@apperceive
Copy link
Author

For use with @sabberworm's PHP-CSS-Parser

Command line usage assuming proper parser install:

curl http://example.com | php seldump.php > selectors.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment