Exemplo n.º 1
0
 public static function GetDouBanModel()
 {
     if (!isset(self::$mDouBanModel)) {
         self::$mDouBanModel = new DouBanModel();
     }
     return self::$mDouBanModel;
 }
Exemplo n.º 2
0
<?php 
//处理单个帖子
require_once "entry.php";
$topicUrl = $argv[1];
$proxyIP = $argv[2];
$proxyPORT = $argv[3];
echo "topicUrl=" . $topicUrl . "\n";
echo "IP=" . $proxyIP . "\n";
echo "PORT=" . $proxyPORT . "\n";
$model = ModelUtil::GetDouBanModel();
$config = FileUtil::GetGlobalConfig();
$imgList = $model->GetPhotoByTopic($topicUrl, $proxyIP, $proxyPORT);
foreach ($imgList as $imgUrl) {
    $cmd = $config['FRAMEWORK_DEFAULT']['PHP_PATH'] . " " . WEB_ROOT . "/download.php " . $imgUrl . " " . $proxyIP . " " . $proxyPORT . "  >/dev/null  &";
    exec($cmd);
}
Exemplo n.º 3
0
 /**
  * Gen private secret key
  * @return string
  */
 public static function genSecretKey()
 {
     return \ModelUtil::randMd5(32);
 }
Exemplo n.º 4
0
 public function GetPhotoByTopic($topicUrl, $ip, $port)
 {
     $data = $this->HttpRequestByProxy($topicUrl, $ip, $port);
     $this->mHtmlDom = new simple_html_dom();
     $contentDom = $this->mHtmlDom->load($data);
     $linkReport = $contentDom->find("div[id=link-report]", 0);
     //没有加载到,可能是网络不通,或者ip被封
     if (!isset($linkReport)) {
         //更换代理,重新尝试加载
         $proxyModel = ModelUtil::GetProxyModel();
         $proxyModel->GetRandomProxy($proxyIP, $proxyPORT);
         $data = $this->HttpRequestByProxy($topicUrl, $proxyIP, $proxyPORT);
         $contentDom = $this->mHtmlDom->load($data);
         $linkReport = $contentDom->find("div[id=link-report]", 0);
         //还是为空,则返回失败
         if (!isset($linkReport)) {
             echo $topicUrl . " is forbidden\n";
             return array();
         }
     }
     $imgDoms = array();
     if (isset($linkReport)) {
         $imgDoms = $linkReport->find("img");
     }
     $photoList = array();
     foreach ($imgDoms as $imgDom) {
         $imgUrl = $imgDom->src;
         $photoList[] = $imgUrl;
     }
     $this->mHtmlDom->clear();
     return $photoList;
 }