Ejemplo n.º 1
0
<?php

include 'ua.class.php';
$detector = new detector($_SERVER["HTTP_USER_AGENT"]);
//new object creator
echo $detector->get("browser");
echo '<br/>';
if ($detector->is("mobilebrowser") == true) {
    echo 'Mobile Browser';
}
echo '<br/>';
echo $detector->get("mobilebrowser");
echo '<br/>';
if ($detector->get("mobilebrowser") == "Apple iPhone") {
    echo 'Apple iPhone user<br>';
}
echo $detector->get("vipbots");
echo '<br/>';
if ($detector->is("vipbots") == true) {
    echo 'vip BOT';
}
echo '<br/>';
if ($detector->get("vipbots") == 'Google Bot') {
    echo 'GOOGLE BOT YOur WEB SITE';
}
echo '<br/>';
echo $detector->get("robots");
echo '<br/>';
if ($detector->is("robots") == true) {
    echo 'your Robot Web site';
}
Ejemplo n.º 2
0
<?php

set_time_limit(0);
date_default_timezone_set('Asia/Shanghai');
require_once dirname(__FILE__) . '/class.crawler.php';
require_once dirname(__FILE__) . '/class.proxy.php';
require_once dirname(__FILE__) . '/class.detector.php';
$id = 0;
if ($argv[1]) {
    $id = $argv[1];
}
$detector = new detector();
$detector->run($id);
Ejemplo n.º 3
0
set_time_limit(0);
date_default_timezone_set('Asia/Shanghai');
require_once dirname(__FILE__) . '/class.crawler.php';
require_once dirname(__FILE__) . '/class.proxy.php';
require_once dirname(__FILE__) . '/class.detector.php';
$mysqli = new mysqli('10.168.45.191', 'admin', 'txg19831210', 'crawler');
$mysqli->query('SET NAMES gbk');
$queueName = 'q_price';
$params = array('host' => '10.168.45.191', 'port' => 5672, 'login' => 'guest', 'password' => 'guest', 'vhost' => '/kwd');
$conn = new AMQPConnection($params);
$conn->connect();
$channel = new AMQPChannel($conn);
$queue = new AMQPQueue($channel);
$queue->setName($queueName);
$detector = new detector();
while ($message = $queue->get(AMQP_AUTOACK)) {
    $kwd = $message->getBody();
    $kwdObj = unserialize($kwd);
    $price = $detector->run($kwdObj);
    if ($price['start_price'] && $price['end_price']) {
        $sql = "SELECT * FROM price WHERE kid = {$kwdObj->id} LIMIT 1";
        $result = $mysqli->query($sql);
        if ($result->num_rows) {
            $sql = "UPDATE price SET min_price = '{$price['start_price']}', max_price = '{$price['end_price']}', region = '{$price['region']}', crawl_status = 2, last_update = " . time() . " WHERE kid = " . $kwdObj->id;
        } else {
            $sql = "INSERT INTO price SET kid = {$kwdObj->id}, shop_type = '{$kwdObj->shop_type}', min_price = '{$price['start_price']}', max_price = '{$price['end_price']}', region = '{$price['region']}', crawl_status = 2, last_update = " . time();
        }
        echo $sql . "\n";
        $mysqli->query($sql);
    }