<?php

require_once 'tools_ini.php';
require_once 'application.php';
require_once 'DB.php';
$swiches = getopt('d:');
$day = isset($swiches['d']) ? $swiches['d'] : null;
//Initialise
$application_parser = new application_parser();
if (isset($day)) {
    $application_parser->date = getdate(strtotime("-" . $day . " days"));
    $application_parser->run();
} else {
    //Scrape for the last X days (apps already in the database are ignored)
    for ($i = 0; $i < SCRAPE_DELAY; $i++) {
        $application_parser->date = getdate(strtotime("-" . $i . " days"));
        $application_parser->run();
    }
}
//Send email
$application_parser->email_log();
//Parser class
class application_parser
{
    //Properties
    var $date;
    var $log = array();
    var $sleep_interval = 2;
    //how long to wait between scraping each feed
    //Constructor
    function application_parser()
Ejemplo n.º 2
0
<?php

//includes
require_once 'config.php';
require_once 'application_parser.php';
require_once 'mailer.php';
if (!isset($_GET['action'])) {
    print "nothing to see here.";
} else {
    echo "starting action " . $_GET['action'];
}
$action = $_GET['action'];
if ($action == "scrape") {
    //Launch the parser
    $application_parser = new application_parser();
    $application_parser->date = getdate(strtotime("-" . SCRAPE_DELAY . " days"));
    $application_parser->run();
}
if ($action == "mail") {
    //Launch the mailer
    $mailer = new mailer();
    $mailer->run();
}