2017 © Pedro Peláez
 

library simplehtmldom

Simple html dom as a silex service

image

haffoudhi/simplehtmldom

Simple html dom as a silex service

  • Friday, May 9, 2014
  • by MeTheGhost
  • Repository
  • 1 Watchers
  • 2 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

integrating simple_html_dom in silex framework

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)

The Versions

09/05 2014

dev-master

9999999-dev

Simple html dom as a silex service

  Sources   Download

MIT

The Requires

 

silex dom simplehtmldom