dev-master
9999999-devSimple html dom as a silex service
MIT
The Requires
silex dom simplehtmldom
Simple html dom as a silex service
This is a simple silex service which integrates simple html dom into silex as a service ., (*1)
Install instruction :, (*2)
Via Composer : 1 - Add this line to composer file: "haffoudhi/simplehtmldom": "@dev" 2 - Then run composer update. 3 - Register the new service in your bootstrap file $app->register(new Haffoudhi\Silex\SimpleHtmlDomServiceProvider()); Without Composer : 1 - Copy the folder Haffoudhi under the src file of your silex project. 2 - Register the new service in your bootstrap file $app->register(new Haffoudhi\Silex\SimpleHtmlDomServiceProvider());
How to use :, (*3)
Now, afer you installed the service successfully, In your Controller,, (*4)
1 - call the service : $simpleHtmlDom = $app['simpleHtmlDom']; 2 - Use simplehtmldom to get all the links from a string : $content = file_get_contents(__DIR__ . '/anyWebPage.htm'); // $content can be the //result of curl function or the content of html file, it's a string that contains the html source $simpleHtmlDom->load($content); // Find all links foreach($simpleHtmlDom->find('a') as $element) { echo $element->href . '<br/>'; } 3 - Use simplehtmldom to get all the links from a file : $simpleHtmlDom->load_file(__DIR__ . '/anyWebPage.htm'); // we introduce the path to the file //that contains the html source // Find all links foreach($simpleHtmlDom->find('a') as $element) { echo $element->href . '<br/>'; }
Final Notices,, (*5)
1 - Need some assistance in data scraping, web scraping using silex and simple_html_dom 2 - You do have some problems implementing the service
then pull a new request i will answer as soon as possible., (*6)
Simple html dom as a silex service
MIT
silex dom simplehtmldom