作者 刘锟

update

@@ -39,17 +39,64 @@ class Temp extends Command @@ -39,17 +39,64 @@ class Temp extends Command
39 */ 39 */
40 protected $description = '临时脚本(akun)'; 40 protected $description = '临时脚本(akun)';
41 41
42 - public function handle() 42 + public function handle(){
  43 +
  44 + }
  45 +
  46 + /**
  47 + * www.docareco.com批量设置301跳转
  48 + * @author Akun
  49 + * @date 2025/04/21 16:12
  50 + */
  51 + public function setDomain301()
43 { 52 {
  53 + $domain_extend_config = DomainInfo::where('domain', 'www.docareco.com')->value('extend_config');
  54 +
  55 + $domain_origin_list = $domain_extend_config ? array_column($domain_extend_config, 'origin') : [];
  56 +
  57 + //读取csv文件
  58 + $file = 'C:\Users\Akun\Desktop\有排名网页-还未做301-4.21.csv';
  59 + $line_of_text = [];
  60 + try {
  61 + $file_handle = fopen($file, 'r');
  62 + while (!feof($file_handle)) {
  63 + $line_of_text[] = fgetcsv($file_handle, 0, ',');
  64 + }
  65 + fclose($file_handle);
  66 + } catch (\Exception $e) {
  67 + $this->output($e->getMessage());
  68 + }
  69 +
  70 + if (count($line_of_text) > 1) {
  71 + foreach ($line_of_text as $k => $v) {
  72 + if ($k > 0 && $v) {
  73 + $origin = str_replace('https://www.docareco.com', '', $v[0]);
  74 + $target = str_replace('https://www.docareco.com', '', $v[1]);
  75 +
  76 + if (!in_array($origin, $domain_origin_list)) {
  77 + $domain_extend_config[] = [
  78 + 'origin' => $origin,
  79 + 'target' => $target
  80 + ];
  81 + }
  82 + }
  83 + }
  84 + }
  85 +
  86 + DomainInfo::where('domain', 'www.docareco.com')->update(['extend_config' => Arr::a2s($domain_extend_config)]);
44 87
  88 + $this->output('success');
45 } 89 }
46 90
  91 +
  92 +
47 /** 93 /**
48 * 未被标注 特殊前后缀 && 未达标项目 && 优化开始时间 > 2025-01-01 00:00:00 ,开启自动添加聚合页关键词的前后缀关键词配置 94 * 未被标注 特殊前后缀 && 未达标项目 && 优化开始时间 > 2025-01-01 00:00:00 ,开启自动添加聚合页关键词的前后缀关键词配置
49 * @author Akun 95 * @author Akun
50 * @date 2025/04/02 14:00 96 * @date 2025/04/02 14:00
51 */ 97 */
52 - public function changeIsAutoKeywords(){ 98 + public function changeIsAutoKeywords()
  99 + {
53 $project_list = DeployOptimize::where('special', 'not like', '%,8,%')->where('start_date', '>', '2025-01-01 00:00:00')->get(); 100 $project_list = DeployOptimize::where('special', 'not like', '%,8,%')->where('start_date', '>', '2025-01-01 00:00:00')->get();
54 101
55 foreach ($project_list as $project) { 102 foreach ($project_list as $project) {