Exemplo n.º 1
0
 /**
  * The primary bootstrap for the application.
  *
  * Using dependency injection, this constructor takes a Silex\Application instance
  * which is used to spin-up the entire site.
  *
  * @param Silex\Application $app The main Silex instance.
  *
  * @return void
  */
 public function __construct(Application $app)
 {
     $this->app = $app;
     foreach ($this->crimeURLS as $city => $url) {
         $objCrime = new CrimeConsumer($city, $url);
         $objCrime->consume();
     }
 }
Exemplo n.º 2
0
    echo 'Failed VA Beach';
}
try {
    $consumer = new CrimeConsumer('Norfolk', 'http://hamptonroads.com/newsdata/crime/norfolk/search/rss?me=%2Fnorfolk%2Fsearch&type=&near=&radius=&op=Submit&form_token=9dc84572393ad9c68f54cad6549692f3&form_id=crime_searchform');
    $consumer->consume();
} catch (Exception $e) {
    echo 'Failed Norfolk';
}
try {
    $consumer = new CrimeConsumer('Portsmouth', 'http://hamptonroads.com/newsdata/crime/portsmouth/search/rss?type=&near=&radius=&from%5Bmonth%5D=10&from%5Bday%5D=1&from%5Byear%5D=2015&to%5Bmonth%5D=10&to%5Bday%5D=23&to%5Byear%5D=2015&op=Submit&form_id=crime_searchform');
    $consumer->consume();
} catch (Exception $e) {
    echo 'Failed Portsmouth';
}
try {
    $consumer = new CrimeConsumer('Suffolk', 'http://hamptonroads.com/newsdata/crime/suffolk/search/rss?type=&near=&radius=&from%5Bmonth%5D=10&from%5Bday%5D=1&from%5Byear%5D=2015&to%5Bmonth%5D=10&to%5Bday%5D=23&to%5Byear%5D=2015&op=Submit&form_id=crime_searchform');
    $consumer->consume();
} catch (Exception $E) {
    echo 'Failed Suffolk';
}
class CrimeConsumer
{
    public $scraper;
    public $city;
    public function __construct($city, $url)
    {
        $this->scraper = new Scraper($url);
        $this->city = $city;
    }
    public function consume()
    {