陈德本 před 5 roky
rodič
revize
3fb3819f67

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 5 - 0
.idea/codeStyles/codeStyleConfig.xml

@@ -0,0 +1,5 @@
+<component name="ProjectCodeStyleConfiguration">
+  <state>
+    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
+  </state>
+</component>

+ 15 - 0
.idea/inspectionProfiles/Project_Default.xml

@@ -0,0 +1,15 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0">
+    <option name="myName" value="Project Default" />
+    <inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
+      <Languages>
+        <language minSize="62" name="PHP" />
+      </Languages>
+    </inspection_tool>
+    <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
+      <option name="processCode" value="true" />
+      <option name="processLiterals" value="true" />
+      <option name="processComments" value="true" />
+    </inspection_tool>
+  </profile>
+</component>

+ 6 - 0
.idea/jsLibraryMappings.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="JavaScriptLibraryMappings">
+    <file url="PROJECT" libraries="{jquery, zui}" />
+  </component>
+</project>

+ 6 - 0
.idea/misc.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="JavaScriptSettings">
+    <option name="languageLevel" value="ES6" />
+  </component>
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/wangyating.iml" filepath="$PROJECT_DIR$/.idea/wangyating.iml" />
+    </modules>
+  </component>
+</project>

+ 24 - 0
.idea/php-docker-settings.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="PhpDockerContainerSettings">
+    <list>
+      <map>
+        <entry key="04f620dd-3051-4a5d-a44e-2783e27e3491">
+          <value>
+            <DockerContainerSettings>
+              <option name="version" value="1" />
+              <option name="volumeBindings">
+                <list>
+                  <DockerVolumeBindingImpl>
+                    <option name="containerPath" value="/opt/project" />
+                    <option name="hostPath" value="$PROJECT_DIR$" />
+                  </DockerVolumeBindingImpl>
+                </list>
+              </option>
+            </DockerContainerSettings>
+          </value>
+        </entry>
+      </map>
+    </list>
+  </component>
+</project>

+ 55 - 0
.idea/php.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="PhpIncludePathManager">
+    <include_path>
+      <path value="$PROJECT_DIR$/vendor/league/event" />
+      <path value="$PROJECT_DIR$/vendor/bshaffer/oauth2-server-php" />
+      <path value="$PROJECT_DIR$/vendor/lcobucci/jwt" />
+      <path value="$PROJECT_DIR$/vendor/paragonie/random_compat" />
+      <path value="$PROJECT_DIR$/vendor/composer" />
+      <path value="$PROJECT_DIR$/vendor/psr/http-message" />
+      <path value="$PROJECT_DIR$/vendor/defuse/php-encryption" />
+      <path value="$PROJECT_DIR$/vendor/league/oauth2-server" />
+      <path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
+      <path value="$PROJECT_DIR$/vendor/psr/log" />
+      <path value="$PROJECT_DIR$/vendor/psr/cache" />
+      <path value="$PROJECT_DIR$/vendor/league/flysystem" />
+      <path value="$PROJECT_DIR$/vendor/cache/adapter-common" />
+      <path value="$PROJECT_DIR$/vendor/cache/tag-interop" />
+      <path value="$PROJECT_DIR$/vendor/ralouphie/getallheaders" />
+      <path value="$PROJECT_DIR$/vendor/guzzlehttp/promises" />
+      <path value="$PROJECT_DIR$/vendor/guzzlehttp/psr7" />
+      <path value="$PROJECT_DIR$/vendor/cache/filesystem-adapter" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php70" />
+      <path value="$PROJECT_DIR$/vendor/guzzlehttp/guzzle" />
+      <path value="$PROJECT_DIR$/vendor/jaeger/g-http" />
+      <path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php80" />
+      <path value="$PROJECT_DIR$/vendor/tightenco/collect" />
+      <path value="$PROJECT_DIR$/vendor/jaeger/querylist" />
+      <path value="$PROJECT_DIR$/vendor/jaeger/phpquery-single" />
+      <path value="$PROJECT_DIR$/vendor/markbaker/matrix" />
+      <path value="$PROJECT_DIR$/vendor/phpoffice/phpspreadsheet" />
+      <path value="$PROJECT_DIR$/vendor/markbaker/complex" />
+      <path value="$PROJECT_DIR$/vendor/sabre/uri" />
+      <path value="$PROJECT_DIR$/vendor/sabre/event" />
+      <path value="$PROJECT_DIR$/vendor/jaeger/querylist-rule-baidu" />
+      <path value="$PROJECT_DIR$/vendor/sabre/xml" />
+      <path value="$PROJECT_DIR$/vendor/sabre/http" />
+      <path value="$PROJECT_DIR$/vendor/sabre/vobject" />
+      <path value="$PROJECT_DIR$/vendor/sabre/dav" />
+      <path value="$PROJECT_DIR$/vendor/league/flysystem-webdav" />
+      <path value="$PROJECT_DIR$/vendor/limestonenetworks/php-ipmitool" />
+      <path value="$PROJECT_DIR$/vendor/symfony/process" />
+    </include_path>
+  </component>
+  <component name="PhpUnit">
+    <phpunit_settings>
+      <PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
+    </phpunit_settings>
+  </component>
+</project>

+ 54 - 0
.idea/wangyating.iml

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/vendor/bshaffer/oauth2-server-php" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/cache/adapter-common" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/cache/filesystem-adapter" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/cache/tag-interop" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/defuse/php-encryption" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/guzzle" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/promises" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/psr7" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/jaeger/g-http" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/jaeger/phpquery-single" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/jaeger/querylist" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/jaeger/querylist-rule-baidu" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/lcobucci/jwt" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/league/event" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/league/flysystem" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/league/flysystem-webdav" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/league/oauth2-server" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/limestonenetworks/php-ipmitool" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/markbaker/complex" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/markbaker/matrix" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/paragonie/random_compat" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/phpoffice/phpspreadsheet" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/cache" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-message" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/simple-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/ralouphie/getallheaders" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/sabre/dav" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/sabre/event" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/sabre/http" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/sabre/uri" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/sabre/vobject" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/sabre/xml" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php70" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php80" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/process" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/var-dumper" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/tightenco/collect" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="zui" level="application" />
+    <orderEntry type="library" name="jquery" level="application" />
+  </component>
+</module>

+ 0 - 22
Request.php

@@ -1,22 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: chendeben
- * Date: 2019-01-22
- * Time: 13:38
- */
-
-namespace Heanup;
-
-
-class Request extends \Thread
-{
-    public $url;
-    public $response;
-    public function __construct($url) {
-        $this->url = $url;
-    }
-    public function run() {
-        $this->response = file_get_contents($this->url);
-    }
-}

+ 10 - 10
cli.php

@@ -16,16 +16,15 @@ $settings = [
     'baseUri' => 'https://www.meitu.live:433/remote.php/webdav/',
     'userName' => "wangyating",
     'password' => "wyt4913402",
-    'authType'=>CURLAUTH_BASIC
+    'authType' => CURLAUTH_BASIC
 ];
 $client = new Sabre\DAV\Client($settings);
-$adapter = new League\Flysystem\WebDAV\WebDAVAdapter($client,"/remote.php/webdav");
+$adapter = new League\Flysystem\WebDAV\WebDAVAdapter($client, "/remote.php/webdav");
 $flysystem = new League\Flysystem\Filesystem($adapter);
 $flysystem->addPlugin(new ListFiles());
 $flysystem->addPlugin(new ListPaths());
 
 
-
 $wd = $argv[1];
 $deep = $argv[2] ?: 1;
 $keys = explode(",", $wd);
@@ -60,9 +59,9 @@ $sheet->getStyle("A1:C" . $row)->applyFromArray($styleArray);
 $writer = new Xlsx($spreadsheet);
 
 //$file_path = sprintf(sys_get_temp_dir() . "/%s-%s.xlsx", $wd, date("Y-m-d"));
-$file_path = tempnam(sys_get_temp_dir(), 'baidu');;
+$file_path = tempnam(sys_get_temp_dir(), 'baidu');
 $writer->save($file_path);
-$flysystem->put(sprintf("关键词/关键词拓展/百度/百度为您推荐/%s.xlsx",date("YmdHis")), file_get_contents($file_path));
+$flysystem->put(sprintf("巨量游戏项目/游戏关键词汇总/百度/百度词挖掘/%s.xlsx", date("YmdHis")), file_get_contents($file_path));
 //$data=$flysystem->listFiles("关键词/关键词拓展/百度/百度为您推荐");
 //var_dump($data);
 $spreadsheet->disconnectWorksheets();
@@ -92,18 +91,20 @@ function getRelatedKeywords($wd)
     $rules = [
         'json' => ['.c-tools', 'data-tools'],
     ];
+    $range='.c-container';
     $ql = (new QL\QueryList)->get($url);
-    $rt = $ql->rules($rules)->query()->getData();
+    $rt =  $ql->rules($rules) ->range($range)->query()->getData();
+    $rt=$rt->all();
     $rt = json_decode(json_encode($rt), true);
     $wds = [];
-    foreach ($rt as $item) {
-        $json = json_decode($item['json'], true);
+    foreach ($rt as $val){
+        $json = json_decode($val['json'], true);
         $baiduUrl = substr($json['url'], 30);
         if ($baiduUrl) {
             $_url = "https://sp2.baidu.com/8LUYsjW91Qh3otqbppnN2DJv/link?url=%s&query=%s&cb=jQuery110206243498231922682_1558178381142&data_name=recommend_common_merger_online&format=json&t=%s";
             $_url = sprintf($_url, $baiduUrl, $wd, time() . "000");
             $data = @file_get_contents($_url);
-            $pat = "#1558178381142\((.*)\)#";
+            $pat = "#jQuery.*\((.*)\)#";
             preg_match($pat, $data, $arr);
             $data = json_decode($arr[1], true);
             if ($data['data'][0]['hintData']) {
@@ -127,7 +128,6 @@ function getRelatedKeywords($wd)
                     }
                 }
             }
-//            print_r($data);die();
         }
     }
     return $wds;

+ 2 - 1
composer.json

@@ -6,6 +6,7 @@
         "phpoffice/phpspreadsheet": "^1.6",
         "jaeger/querylist-rule-baidu": "^4.0",
         "league/flysystem": "^1.0",
-        "league/flysystem-webdav": "^1.0"
+        "league/flysystem-webdav": "^1.0",
+        "limestonenetworks/php-ipmitool": "^1.0"
     }
 }

+ 0 - 112
explore.php

@@ -1,112 +0,0 @@
-<?php
-set_time_limit(0);
-/**
- * Created by PhpStorm.
- * User: chendeben
- * Date: 2019-01-16
- * Time: 17:06
- */
-require_once('vendor/autoload.php');
-
-use PhpOffice\PhpSpreadsheet\Spreadsheet;
-use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
-use QL\QueryList;
-
-//$ql = QueryList::get('https://www.baidu.com/s?wd=QueryList');
-//$titles = $ql->find('h3>a')->texts(); //获取搜索结果标题列表
-//$links = $ql->find('h3>a')->attrs('href'); //获取搜索结果链接列表
-//print_r($titles);
-//print_r($links);
-//die();
-
-
-$wd = $_REQUEST['wd'];
-if (!$wd) {
-    ?>
-    <!DOCTYPE html>
-    <html lang="zh-cn">
-    <head>
-        <meta charset="utf-8">
-        <meta http-equiv="X-UA-Compatible" content="IE=edge">
-        <meta name="viewport" content="width=device-width, initial-scale=1">
-        <!-- ZUI 标准版压缩后的 CSS 文件 -->
-        <link rel="stylesheet" href="//cdn.bootcss.com/zui/1.8.1/css/zui.min.css">
-
-        <!-- ZUI Javascript 依赖 jQuery -->
-        <script src="//cdn.bootcss.com/zui/1.8.1/lib/jquery/jquery.js"></script>
-        <!-- ZUI 标准版压缩后的 JavaScript 文件 -->
-        <script src="//cdn.bootcss.com/zui/1.8.1/js/zui.min.js"></script>
-    </head>
-    <body>
-    <br>
-    <br>
-    <br>
-    <br>
-    <form method="post" action="">
-        <div class="container">
-            <div class="row">
-                <div class="col-md-9">
-                <textarea style="height: 300px;" class="form-control" rows="3" placeholder="请输入关键词,一行一个" name="wd"></textarea>
-                </div>
-            </div>
-            <div class="row" style="margin-top: 5px;">
-                <div class="col-md-2 col-md-offset-8">
-                    <input type="submit"  class="btn btn-primary  btn-lg" value="提交"/>
-                </div>
-            </div>
-        </div>
-
-    </form>
-
-    </body>
-    </html>
-    <?php
-} else {
-    $_url = "http://www.baidu.com/s?ie=UTF-8&wd=%s";
-    $origin_str = [';', ';', ',', ',', ' ',"\r\n"];
-    $des_str = [',', ',', ',', ',', ',',','];
-    $wd = str_replace($origin_str, $des_str, $wd);
-    $keys = explode(",", $wd);
-    $result = [];
-    foreach ($keys as $key) {
-        $url = sprintf($_url, $key);
-        $ql = QueryList::get($url);
-        $table = $ql->find("#rs > table");
-        $tableRows = $table->find('tr')->map(function ($row) {
-            return $row->find('th')->texts()->all();
-        });
-        $data = $tableRows->all();
-        $_result = [];
-        foreach ($data as $item) {
-            foreach ($item as $value) {
-                $_result[] = $value;
-            }
-        }
-        $result[] = [
-            'keyword' => $key,
-            'related_keywords' => $_result
-        ];
-    }
-    $spreadsheet = new Spreadsheet();
-    $sheet = $spreadsheet->getActiveSheet();
-    $row = 1;
-    foreach ($result as $key => $item) {
-        $sheet->setCellValueByColumnAndRow(1, $row++, $item['keyword']);
-        foreach ($item['related_keywords'] as $related_keyword) {
-            $sheet->setCellValueByColumnAndRow(2, $row++, $related_keyword);
-        }
-        $row++;
-    }
-    $writer = new Xlsx($spreadsheet);
-    header("Pragma: public");
-    header("Expires: 0");
-    header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
-    header("Content-Type:application/force-download");
-    header("Content-Type:application/vnd.ms-execl");
-    header("Content-Type:application/octet-stream");
-    header("Content-Type:application/download");
-    header('Content-Disposition:attachment;filename="相关搜索词.xlsx"');
-    header("Content-Transfer-Encoding:binary");
-    $writer->save('php://output');
-    $spreadsheet->disconnectWorksheets();
-}

+ 1 - 1
hintData.php

@@ -80,7 +80,7 @@ if (!$wd) {
     $wd = str_replace($origin_str, $des_str, $wd);
     $deep=$_REQUEST['deep']?:1;
 //    echo $cmd=sprintf("nohup /usr/local/php7.2/bin/php /home/wwwroot/wyt.phplife.net/cli.php %s %s > /home/wwwroot/wyt.phplife.net/wangyating.log &",$wd,$deep);
-    $cmd=sprintf("/usr/local/php7.2/bin/php /home/wwwroot/wyt.phplife.net/cli.php %s %s &",$wd,$deep);
+    $cmd=sprintf("php /www/wangyating/cli.php %s %s &",$wd,$deep);
 //    $cmd=sprintf("php /www/wyt.phplife.net/cli.php %s %s &",$wd,$deep);
     pclose(popen($cmd, 'r'));
 //    $str= shell_exec($cmd);

+ 83 - 0
index.html

@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>工具聚合页</title>
+    <!-- ZUI 标准版压缩后的 CSS 文件 -->
+    <link rel="stylesheet" href="//cdn.bootcss.com/zui/1.8.1/css/zui.min.css">
+
+    <!-- ZUI Javascript 依赖 jQuery -->
+    <script src="//cdn.bootcss.com/zui/1.8.1/lib/jquery/jquery.js"></script>
+    <!-- ZUI 标准版压缩后的 JavaScript 文件 -->
+    <script src="//cdn.bootcss.com/zui/1.8.1/js/zui.min.js"></script>
+</head>
+<body>
+<div class="container">
+    <div class="row" style="margin-top: 50px">
+        <div class="col-md-3 col-md-offset-1">
+            <form method="post" action="related.php">
+                <div class="form-group">
+                    <label for="related">相关搜索词:</label>
+                    <textarea id="related" class="form-control" rows="3" placeholder="请输入关键词,一行一个"
+                              style="margin-top: 10px"
+                              name="wd"></textarea>
+                </div>
+                <input type="submit" class="btn btn-primary  btn-lg" style="float: right" value="提交"/>
+            </form>
+        </div>
+
+        <div class="col-md-3 col-md-offset-1">
+            <form method="post" action="baidu.php">
+                <div class="form-group">
+                    <label for="other_search">百度其他人还在搜:</label>
+                    <textarea id="other_search" class="form-control" rows="3" placeholder="请输入关键词,一行一个"
+                              style="margin-top: 10px"
+                              name="wd"></textarea>
+                </div>
+                <input type="submit" class="btn btn-primary  btn-lg" style="float: right" value="提交"/>
+            </form>
+        </div>
+
+        <div class="col-md-3  col-md-offset-1">
+            <form method="post" action="aizhan.php">
+                <div class="form-group">
+                    <label for="aizhan">爱站关键词挖掘:</label>
+                    <input id="aizhan" type="text" class="form-control" style="margin-top: 10px" placeholder="请输入关键词"
+                           name="t"/>
+                </div>
+                <input type="submit" class="btn btn-primary  btn-lg" style="float: right" value="提交"/>
+            </form>
+        </div>
+
+    </div>
+
+    <div class="row" style="margin-top: 50px">
+        <div class="col-md-3 col-md-offset-1">
+            <form method="post" action="hintData.php">
+                <div class="form-group">
+                    <label for="hitData">为你推荐-相关搜索词:</label>
+                    <textarea id="hitData" class="form-control" rows="3" placeholder="请输入关键词,一行一个"
+                              style="margin-top: 10px"
+                              name="wd"></textarea>
+                </div>
+                <div class="form-group">
+                    <label for="deep"> 爬取深度</label>
+                    <select class="form-control" id="deep" name="deep">
+                        <option value="1">1</option>
+                        <option value="2">2</option>
+                        <option value="3">3</option>
+                    </select>
+                    <section class="content">
+                        <p class="text-success">该功能将异步提交任务,并保存至云盘文件夹:巨量游戏项目/游戏关键词汇总/百度/百度词挖掘</p>
+                    </section>
+                </div>
+                <input type="submit" class="btn btn-primary  btn-lg" style="float: right" value="提交"/>
+            </form>
+        </div>
+
+
+    </div>
+</div>
+
+</body>
+</html>

+ 0 - 80
rank.php

@@ -1,80 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: chendeben
- * Date: 2019-01-21
- * Time: 09:34
- */
-
-//use QL\QueryList;
-
-include 'vendor/autoload.php';
-$key_word = $_GET['wd'];
-$domain=$_GET['host']?:"www.cnanzhi.com";
-$_url = "http://www.baidu.com/s?rn=10&ie=UTF-8&wd=%s";
-
-
-$range = '.c-container';
-$rules = [
-    'result' => ['h3', 'text'],
-    // 采集链接
-    'link' => ['h3>a', 'href'],
-];
-
-
-$domains = [
-    ''
-];
-$flag=false;
-
-for ($i=0;$i<6;$i++){
-    $url = sprintf($_url,$key_word);
-    if ($i>0){
-        $url.="&pn=".($i*10);
-    }
-    $ql = (new QL\QueryList)->get($url);
-    $data = $ql->rules($rules)->range($range)->query()->getData();
-    $data = $data->all();
-//    $data=array_map(function ($a){return get_headers($a['link']);}, $data);
-//var_dump($data);
-//die();
-    foreach ($data as $key=>$item) {
-        $header=getRealUrl($item['link']);
-//        var_dump(parse_url($header)['host']);
-//        die();
-        if (parse_url($header)['host']==$domain){
-            $rank=$key+$i*10;
-            $real_url=$header;
-            break;
-        }
-    }
-    if (isset($rank)){
-        break;
-    }
-}
-if (isset($rank)){
-    echo sprintf( "排名第%s位,真实URL为<br>%s",$rank+1,$real_url);
-}else{
-    echo "不在前5页里";
-}
-
-
-function getRealUrl($url)
-{
-    //得到百度跳转的真正地址
-    $header = @get_headers($url, 1);
-//    var_dump($header);die();
-    if (strpos($header[0], '301') || strpos($header[0], '302')) {
-        if (is_array($header['Location'])) {
-            //return $header['Location'][count($header['Location'])-1];
-            $_url = $header['Location'][0];
-        } else {
-            $_url = $header['Location'];
-        }
-    } else {
-        $_url = $url;
-    }
-    return $_url;
-//    $url = parse_url($_url);
-//    return $url['host'];
-}

+ 22 - 25
index.php → related.php

@@ -9,6 +9,7 @@ set_time_limit(0);
 require_once('vendor/autoload.php');
 
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
 use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
 use QL\QueryList;
 
@@ -84,7 +85,7 @@ if (!$wd) {
         $row++;
     }
 
-    $shenma_sheet=new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet();
+    $shenma_sheet=new Worksheet();
     $row = 1;
     foreach ($shenma as $key => $item) {
         $shenma_sheet->setCellValueByColumnAndRow(1, $row++, $item['keyword']);
@@ -96,7 +97,7 @@ if (!$wd) {
     $shenma_sheet->setTitle("神马");
     $spreadsheet->addSheet($shenma_sheet);
 
-    $sougou_sheet=new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet();
+    $sougou_sheet=new Worksheet();
     $row = 1;
     foreach ($sougou as $key => $item) {
         $sougou_sheet->setCellValueByColumnAndRow(1, $row++, $item['keyword']);
@@ -108,7 +109,7 @@ if (!$wd) {
     $sougou_sheet->setTitle("搜狗");
     $spreadsheet->addSheet($sougou_sheet);
 
-    $so_360_sheet=new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet();
+    $so_360_sheet=new Worksheet();
     $row = 1;
     foreach ($so_360 as $key => $item) {
         $so_360_sheet->setCellValueByColumnAndRow(1, $row++, $item['keyword']);
@@ -161,24 +162,14 @@ function baidu($wd){
 }
 
 function shenma($keys){
-    $url="https://yz.m.sm.cn/s?q=%s&by=submit&uc_param_str=dnntnwvepffrgibijbprsvdsdichei&from=ws984141";
+    $url="https://m.sm.cn/s?q=%s&from=smor&safe=1&snum=20";
     $result=[];
     foreach ($keys as $key) {
         $url = sprintf($url, $key);
-        $ql = QueryList::get($url);
-        $table = $ql->find(".ali_rel > ul > li");
-        $tableRows = $table->map(function ($row) {
-            return $row->find('a')->texts()->all();
-        });
-        $data = $tableRows->all();
-//        var_dump($data);
-//        die();
         $_result = [];
-        foreach ($data as $item) {
-            foreach ($item as $value) {
-                $_result[] = $value;
-            }
-        }
+        $ql = (new QL\QueryList)->get($url);
+        $_data =$ql->find(".js-c-e-button-text")->texts()->all();
+        $_result=array_merge($_result,$_data);
         $result[] = [
             'keyword' => $key,
             'related_keywords' => $_result
@@ -191,26 +182,32 @@ function sougou($keys){
     $url="https://www.sogou.com/web?query=%s";
     $result=[];
     foreach ($keys as $key) {
+        $_result = [];
         $url = sprintf($url, $key);
-        $ql = QueryList::get($url);
+        $ql = (new QL\QueryList)->get($url);
+        $_data =$ql->find("#float_uphint a")->texts()->all();
+        $_result=array_merge($_result,$_data);
+
+        $_data =$ql->find(".hint-mid a")->texts()->all();
+        $_result=array_merge($_result,$_data);
+
+
         $table = $ql->find("#hint_container");
-        $tableRows = $table->find('tr')->map(function ($row) {
+        $tableRows =$table->find("tr")->map(function ($row){
             return $row->find('a')->texts()->all();
         });
+
         $data = $tableRows->all();
-//        var_dump($data);
-//        die();
-        $_result = [];
         foreach ($data as $item) {
-            foreach ($item as $value) {
-                $_result[] = $value;
-            }
+            $_result=array_merge($_result,$item);
         }
         $result[] = [
             'keyword' => $key,
             'related_keywords' => $_result
         ];
+        
     }
+    
     return $result;
 }
 function so_360($keys){

+ 0 - 31
server.php

@@ -1,31 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: chendeben
- * Date: 2019-01-11
- * Time: 17:15
- */
-$dsn= 'mysql:dbname=oauth_test;host=192.168.41.215:3307';
-$username = 'root';
-$password = 'root';
-
-// 错误报告(这毕竟是一个演示!)
-ini_set('display_errors',1);error_reporting(E_ALL);
-
-// 自动加载
-require_once('vendor/autoload.php');
-$storage = new OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password));
-
-// 通过存储对象或对象数组存储的oauth2服务器类
-$server = new OAuth2\Server($storage);
-
-// 授权码 有效期只有30秒
-$server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage));
-
-// 客户端证书
-$server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage));
-
-// 用户凭据
-$server->addGrantType(new OAuth2\GrantType\UserCredentials($storage));
-// 刷新令牌  启用这个会报错,原因未知
- $server->addGrantType(new OAuth2\GrantType\RefreshToken($refreshStorage));

+ 0 - 30
test.php

@@ -1,30 +0,0 @@
-<?php
-
-/**
- * Created by PhpStorm.
- * User: chendeben
- * Date: 2019-01-11
- * Time: 17:41
- */
-
-
-
-echo getRealUrl($_GET['url']);
-
-function getRealUrl($url)
-{
-    //得到百度跳转的真正地址
-    $header = get_headers($url, 1);
-    if (strpos($header[0], '301') || strpos($header[0], '302')) {
-        if (is_array($header['Location'])) {
-            //return $header['Location'][count($header['Location'])-1];
-            $_url = $header['Location'][0];
-        } else {
-            $_url = $header['Location'];
-        }
-    } else {
-        $_url = $url;
-    }
-    $url = parse_url($_url);
-    return $url['host'];
-}

+ 0 - 18
trait_test.php

@@ -1,18 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: chendeben
- * Date: 2019-01-12
- * Time: 11:14
- */
-trait trait_test{
-    function test_1($a,$b){
-        return round($a/$b);
-    }
-
-}
-trait trait_test2{
-    function test_2($a,$b){
-        return round($a*$b);
-    }
-}