您好,登錄后才能下訂單哦!
// exec('mongoexport -h 192.168.6.97 --port 40000 -d fenjianlidb -c fenjianli -f "meta_info.file_path" -q "{\'create_time\':{\'$gte\': \'1487088000\',\'$lte\': \'1487644200\'}}" -o ' . $save_path .'middle.txt', $ret); //window平臺
//php 執行
exec('mongoexport -h 192.168.6.97 --port 40000 -d zhengliangdb -c newzengliang -f "meta_info.file_path" -q \'{create_time:{$gte: 1487645408,$lte: 1487646251}}\' -o /data/work_time/work0221/testMid/middle.txt', $ret); //Linux 成功 (切記轉移) mongoexport --help 查看
--------------------------------------測試代碼-----------------------------------------
<?php
/**
* @Author: lixiaozhu
* @Date: 2016-09-21 12:51:55
* @Last Modified by: lixiaozhu
* @Last Modified time: 2017-01-20 18:50:24
*/
set_time_limit(0);
// $save_path = 'D:/phpStudy/WWW/test01/mongo/test0221/';
$save_path = '/data/work_time/work0221/testMid/';
//中間件
// exec('mongoexport -h 192.168.6.97 --port 40000 -d fenjianlidb -c fenjianli -f "meta_info.file_path" -q "{\'create_time\':{\'$gte\': \'1487088000\',\'$lte\': \'1487644200\'}}" -o ' . $save_path .'middle.txt', $ret); //window平臺
//php 執行
exec('mongoexport -h 192.168.6.97 --port 40000 -d zhengliangdb -c newzengliang -f "meta_info.file_path" -q \'{create_time:{$gte: 1487645408,$lte: 1487646251}}\' -o /data/work_time/work0221/testMid/middle.txt', $ret); //Linux 成功
$groups = array(
'group1' => 'http://192.168.6.49/',
'group2' => 'http://192.168.6.50/',
);
$content = file_get_contents($save_path . 'middle.txt');
$list = preg_split('/\s+/', $content);
$prefix = date('YmdH');
foreach ($list as $key => $item) {
echo $key++, PHP_EOL;
$item = json_decode($item, true);
$file_path = trim($item['meta_info']['file_path']);
$group = substr($file_path, 0, 6);
if (isset($groups[$group])) {
$url = $groups[$group] . $file_path;
$content = file_get_contents($url);
if(false !== strpos($content,'zhaopin.com')){ //可能會有 zhaopin.cn localhost/qiaoda/zhilian/z1.html
error_log($url . PHP_EOL, 3, $save_path . $prefix .'_zhilian.txt');
} elseif (false !== strpos($content,'51job.com')){
error_log($url . PHP_EOL, 3, $save_path . $prefix .'_51job.txt');
} elseif (false !== strpos($content,'liepin.com')){
error_log($url . PHP_EOL, 3, $save_path . $prefix .'_liepin.txt');
} elseif (false !== strpos($content,'ganji.com')){
error_log($url . PHP_EOL, 3, $save_path . $prefix . '_ganji.txt');
} elseif (false !== strpos($content, '58.com')){
error_log($url . PHP_EOL, 3, $save_path . $prefix . '_58tongchen.txt');
} elseif (false !== strpos($content, 'chinahr.com')){
error_log($url . PHP_EOL, 3, $save_path . $prefix . '_YCjianli.txt');
} else {
error_log($url . PHP_EOL, 3, $save_path . $prefix . '_other.txt');
}
} else {
echo 'mubanFileError';
error_log($file_path . PHP_EOL, 3, $save_path . $prefix . '_mubanFileError.txt');
}
unset($content);
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。