Kaynağa Gözat

kw basic search

ming 3 yıl önce
ebeveyn
işleme
0d6aef14ae
4 değiştirilmiş dosya ile 479 ekleme ve 39 silme
  1. 1 8
      similar_web/index.html
  2. 58 30
      similar_web/keywords.html
  3. 418 0
      similar_web/kw_new.html
  4. 2 1
      similar_web/main.py

+ 1 - 8
similar_web/index.html

@@ -390,14 +390,7 @@ function closeNav() {
               closeNav()
             }
         });
-        
-        
-       
-      //   sitename.innerHTML =response.data
-
-      // var bar = document.getElementById('bar');
-
-      // var barChart = echarts.init(bar);
+      
     }
 
 

+ 58 - 30
similar_web/keywords.html

@@ -287,7 +287,9 @@
       </div>
     </div>
   </div>
-  
+  <footer class="footer text-center p-4 bg-white">
+    <div class="text-muted"> © 2021 Copyright: Googo Website Traffic</div>
+  </footer>
   <script
   src="https://code.jquery.com/jquery-3.6.0.min.js"
   integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
@@ -295,7 +297,7 @@
 <script src="https://unpkg.com/js-datepicker"></script>
 
 <script>
-const input = document.getElementById("following_keys");
+const input = document.getElementById("search_query");
 const search__btn = document.getElementById("search__btn");
 const picker_str = datepicker('#daterng1', {
   id: 1
@@ -320,33 +322,61 @@ input.addEventListener("keyup", function(event) {
   }
 });
 $(document).ready(function () {
-//$('#dtBasicExample').DataTable();
-//$('.dataTables_length').addClass('bs-select');
-//});
-
+$('#dtBasicExample').DataTable();
+$('.dataTables_length').addClass('bs-select');
+});
 
+const myChart = echarts.init(document.getElementById('main'));
+let option;
 
 function check_form(){
-  dataOBJ = {'keyword':$('#following_keys').val()}
-  objstr = JSON.stringify(dataOBJ);
-  $.ajax({
-            url: 'http://www.googo.org:8001/kw_dm',
-            //url: 'http://www.choozmo.com:8888/qqreq',
-            dataType : 'json', // 預期從server接收的資料型態
-            contentType : 'application/json; charset=utf-8', // 要送到server的資料型態
-            type: 'post',
-            data: objstr,
-            success: function(suc_data) {
-                alert('hi im here')
+    const qry = document.getElementById('search_query').value;
+    axios.get('http://www.googo.org:8080/domain/' + qry)
+    .then((response) => {
+      const sitename = document.getElementById('sitename');
+      const sitetitle = document.getElementById('sitetitle');
+      const descriptions = document.getElementById('descriptions');
+      const globalrank = document.getElementById('globalrank');
+      const countryrank = document.getElementById('countryrank');    
+      const category = document.getElementById('category');    
 
-              },
-            //data:JSON.stringify({n1:"12",n2:"22"}),
-            error: function (error) {
-              alert('此網頁無法查詢!')
-              closeNav()
-            }
-        });
+      console.log(response.data); 
+      //    alert(response.data.SiteName);
+      //    var obj = JSON.parse(response.data);
+      //    alert(obj);
+      itename.textContent =response.data.SiteName;
+      descriptions.textContent=response.data.Description;
+      globalrank.textContent=response.data.GlobalRank.Rank;
+      sitetitle.textContent=response.data.Title;
+      countryrank.textContent=response.data.CountryRank.Rank;
+      category.textContent=response.data.Category;
+  
+      const key_ary=[];
+      const val_ary=[];
+      for (const [key, value] of Object.entries(response.data.EstimatedMonthlyVisits)) {
+        key_ary.push(key);
+        val_ary.push(value);
+      }
+      option = {
+          xAxis: {
+              type: 'category',
+              boundaryGap: false,
+              data: key_ary
+          },
+          yAxis: {
+              type: 'value'
+          },
+          series: [{
+              data: val_ary,
+              type: 'line',
+              areaStyle: {}
+          }]
+      };
+          myChart.setOption(option);
+      //    sitename.innerHTML =response.data
+      var bar = document.getElementById('bar');
 
+var barChart = echarts.init(bar);
 let traffics;
 
 traffics = {
@@ -391,18 +421,16 @@ traffics = {
     ]
 };
 
-  traffics.setOption(traffics);
+  traffics && barChart.setOption(traffics);
       console.log(response.status);
       console.log(response.statusText);
       console.log(response.headers);
       console.log(response.config);
-  
+    });
   }
 </script>
 
 </body>
 
-    <footer class="footer text-center p-4 bg-white">
-    <div class="text-muted"> © 2021 Copyright: Googo Website Traffic</div>
-  </footer>
-</html>
+    
+</html>

+ 418 - 0
similar_web/kw_new.html

@@ -0,0 +1,418 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <meta http-equiv="X-UA-Compatible" content="ie=edge">
+  <title>Googo Website Traffic</title>
+  <!-- Font Awesome -->
+  <link
+    href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
+    rel="stylesheet"
+  />
+  <!-- Google Fonts -->
+  <link
+    href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
+    rel="stylesheet"
+  />
+  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
+    integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
+  <!-- MDB -->
+  <link
+    href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/3.3.0/mdb.min.css"
+    rel="stylesheet"
+  />
+  <link rel="stylesheet" href="https://unpkg.com/js-datepicker/dist/datepicker.min.css">
+  <link rel="stylesheet" type="text/css" href="reset.css">
+  <link rel="stylesheet" type="text/css" href="main.css">
+  <!-- MDB -->
+  <script
+    type="text/javascript"
+    src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/3.3.0/mdb.min.js"
+  ></script>    
+  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
+  <script src="echarts.min.js"></script>
+</head>
+<body class="color__grey">
+  <div id="myNav" class="overlay">
+    <div class="overlay-content">
+      <a href="#">載入資料中,請稍候</a>
+    </div>
+  </div>
+<!-- Navbar -->
+  <nav class="navbar navbar-expand-lg navbar-light bg-white">
+    <!-- Container wrapper -->
+    <div class="container-fluid">
+      
+      <!-- Navbar brand -->
+      <a class="navbar-brand" href="#">Googo Website Traffic</a>
+  
+      <!-- Toggle button -->
+      <button class="navbar-toggler" type="button" data-mdb-toggle="collapse"
+        data-mdb-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
+        aria-label="Toggle navigation">
+        <i class="fas fa-bars text-light"></i>
+      </button>
+  
+      <!-- Collapsible wrapper -->
+      <div class="collapse navbar-collapse" id="navbarSupportedContent">
+        <!-- Left links -->
+        <ul class="navbar-nav me-auto d-flex flex-row mt-3 mt-lg-0">
+          <li class="nav-item text-center mx-2 mx-lg-1">
+            <a class="nav-link active" aria-current="page" href="index.html">
+              <div>
+                <i class="fas fa-home fa-lg mb-1"></i>
+              </div>
+              Home
+            </a>
+          </li>
+          <li class="nav-item text-center mx-2 mx-lg-1">
+            <a class="nav-link" href="http://news.google.com">
+              <div>
+                <i class="fas fa-globe-americas fa-lg mb-1"></i>
+                <!-- <span class="badge rounded-pill badge-notification bg-success">11</span> -->
+              </div>
+              News
+            </a>
+          </li>
+          <li class="nav-item text-center mx-2 mx-lg-1">
+            <a class="nav-link" href="keywords.html">
+              <div>
+                <i class="fab fa-korvue fa-lg mb-1"></i>
+                <!-- <span class="badge rounded-pill badge-notification bg-success">11</span> -->
+              </div>
+              Keywords
+            </a>
+          </li>
+        </ul>
+        <!-- Right links -->
+      </div>
+      <!-- Collapsible wrapper -->
+    </div>
+    <!-- Container wrapper -->
+  </nav>
+  <!-- Navbar -->
+
+  <div class="container">
+    <div class="row">
+      <!-- <div class="col-1 col-lg-1"></div> -->
+      <div class="col-12 col-12">
+          <!-- Search form  -->
+        <form id="searchform" class="d-flex input-group search__form align-item-center keyword_add" >
+          <input type="search" class="form-control search__bar" placeholder="新增追蹤關鍵字" aria-label="Domain Name" id="following_keys"/>
+          <button class="btn btn-primary search__btn" type="button" data-mdb-ripple-color="dark" id="search__btn">
+              加入
+          </button>
+        </form>
+        <div class="keyword_total mx-auto mb-4">目前有 <strong>N</strong> 個追蹤關鍵字</div>
+        <div class="date__input mb-3">
+          <label for="daterng">開始日期:</label><input type="text" name="daterng" id="daterng1">
+          <label for="daterng">結束日期:</label><input type="text" name="daterng" id="daterng2">
+          <button class='sub__date btn'>套用</button>
+        </div>
+            <div class="text-muted mb-2 border-bottom">追蹤關鍵字排名</div>
+            <div class="row g-5 mb-3">
+              <div class="col-sm-4">
+                <div class="card p-3">
+                  <div class="card-body text-center">
+                    <h5 class="card-title card__rank__title mb-2">排名前一頁關鍵字</h5>
+                    <p class="card-text" >
+                    </p>
+                    <span href="#" class="rank__mark"><strong id="globalrank" class="rank_num">1000</strong>個</span>
+                  </div>
+                </div>
+              </div>
+              <div class="col-sm-4">
+                <div class="card p-3">
+                  <div class="card-body text-center">
+                    <h5 class="card-title card__rank__title mb-2">排名前三頁關鍵字</h5>
+                    <p class="card-text">
+                    </p>
+                    <span href="#" class="rank__mark"><strong id="countryrank" class="rank_num">100</strong>個</span>
+                  </div>
+                </div>
+              </div>
+              <div class="col-sm-4">
+                <div class="card p-3">
+                  <div class="card-body text-center">
+                    <h5 class="card-title card__rank__title mb-2"><i class="fas fa-tags"></i>排名前十頁關鍵字</h5>
+                    <p class="card-text card__rank__cat" id="category">
+                    </p>
+                    <span href="#" class="rank__mark"><strong id="countryrank" class="rank_num">100</strong>個</span>
+                  </div>
+                </div>
+              </div>
+            </div>
+            <div class="text-muted mb-2">追蹤關鍵字列表</div>
+            <table id="dtBasicExample" class="table" cellspacing="0" width="100%">
+              <thead>
+                <tr>
+                  <th class="th-sm">關鍵字
+                  </th>
+                  <th class="th-sm">排名
+                  </th>
+                  <th class="th-sm">搜尋量
+                  </th>
+                  <th class="th-sm">曝光數
+                  </th>
+                  <th class="th-sm">CTR
+                  </th>
+                  <th class="th-sm">頁面搜尋流量
+                  </th>
+                  <th></th>
+                </tr>
+              </thead>
+              <tbody>
+                <tr>
+                  <td>Tiger Nixon</td>
+                  <td>System Architect</td>
+                  <td>Edinburgh</td>
+                  <td>61</td>
+                  <td>2011/04/25</td>
+                  <td>989</td>
+                  <td><i class="fas fa-trash-alt"></i></td>
+                </tr>
+                <tr>
+                  <td>Garrett Winters</td>
+                  <td>Accountant</td>
+                  <td>Tokyo</td>
+                  <td>63</td>
+                  <td>2011/07/25</td>
+                  <td>989</td>
+                  <td><i class="fas fa-trash-alt"></i></td>
+                </tr>
+                <tr>
+                  <td>Ashton Cox</td>
+                  <td>Junior Technical Author</td>
+                  <td>San Francisco</td>
+                  <td>66</td>
+                  <td>2009/01/12</td>
+                  <td>989</td>
+                  <td><i class="fas fa-trash-alt"></i></td>
+                </tr>
+              </tbody>
+            </table>
+            <div class="text-muted mb-2">搜尋關鍵字現況(連google search console 資料)</div>
+            <table id="dtBasicExample" class="table" cellspacing="0" width="100%">
+              <thead>
+                <tr>
+                  <th class="th-sm">關鍵字
+                  </th>
+                  <th class="th-sm">排名
+                  </th>
+                  <th class="th-sm">搜尋量
+                  </th>
+                  <th class="th-sm">曝光數
+                  </th>
+                  <th class="th-sm">CTR
+                  </th>
+                  <th class="th-sm">頁面搜尋流量
+                  </th>
+                  <th></th>
+                </tr>
+              </thead>
+              <tbody>
+                <tr>
+                  <td>Tiger Nixon</td>
+                  <td>System Architect</td>
+                  <td>Edinburgh</td>
+                  <td>61</td>
+                  <td>2011/04/25</td>
+                  <td>989</td>
+                  <td><i class="fas fa-trash-alt"></i></td>
+                </tr>
+                <tr>
+                  <td>Garrett Winters</td>
+                  <td>Accountant</td>
+                  <td>Tokyo</td>
+                  <td>63</td>
+                  <td>2011/07/25</td>
+                  <td>989</td>
+                  <td><i class="fas fa-trash-alt"></i></td>
+                </tr>
+                <tr>
+                  <td>Ashton Cox</td>
+                  <td>Junior Technical Author</td>
+                  <td>San Francisco</td>
+                  <td>66</td>
+                  <td>2009/01/12</td>
+                  <td>989</td>
+                  <td><i class="fas fa-trash-alt"></i></td>
+                </tr>
+              </tbody>
+            </table>
+            <div class="text-muted mb-2">關鍵字建議</div>
+            <table id="dtBasicExample" class="table" cellspacing="0" width="100%">
+              <thead>
+                <tr>
+                  <th class="th-sm">關鍵字
+                  </th>
+                  <th class="th-sm">排名
+                  </th>
+                  <th class="th-sm">搜尋量
+                  </th>
+                  <th class="th-sm">曝光數
+                  </th>
+                  <th class="th-sm">CTR
+                  </th>
+                  <th class="th-sm">頁面搜尋流量
+                  </th>
+                  <th></th>
+                </tr>
+              </thead>
+              <tbody>
+                <tr>
+                  <td>Tiger Nixon</td>
+                  <td>System Architect</td>
+                  <td>Edinburgh</td>
+                  <td>61</td>
+                  <td>2011/04/25</td>
+                  <td>989</td>
+                  <td><i class="fas fa-trash-alt"></i></td>
+                </tr>
+                <tr>
+                  <td>Garrett Winters</td>
+                  <td>Accountant</td>
+                  <td>Tokyo</td>
+                  <td>63</td>
+                  <td>2011/07/25</td>
+                  <td>989</td>
+                  <td><i class="fas fa-trash-alt"></i></td>
+                </tr>
+                <tr>
+                  <td>Ashton Cox</td>
+                  <td>Junior Technical Author</td>
+                  <td>San Francisco</td>
+                  <td>66</td>
+                  <td>2009/01/12</td>
+                  <td>989</td>
+                  <td><i class="fas fa-trash-alt"></i></td>
+                </tr>
+              </tbody>
+            </table>
+      </div>
+    </div>
+  </div>
+  
+  <script
+  src="https://code.jquery.com/jquery-3.6.0.min.js"
+  integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
+  crossorigin="anonymous"></script>
+<script src="https://unpkg.com/js-datepicker"></script>
+
+<script>
+function openNav() {
+  document.getElementById("myNav").style.display = "block";
+}
+function closeNav() {
+  document.getElementById("myNav").style.display = "none";
+}
+
+const input = document.getElementById("following_keys");
+const search__btn = document.getElementById("search__btn");
+const picker_str = datepicker('#daterng1', {
+  id: 1
+});
+const picker_end = datepicker('#daterng2', {
+  id: 1
+});
+$('.sub__date').click(function(e){
+  e.preventDefault();
+  console.log(picker_end.getRange());
+});
+search__btn.addEventListener("click", function(e) {
+  //e.preventDefault();
+  check_form();
+});
+$('#following_keys').keydown(function(e){
+    if (event.keyCode == 13){
+      document.getElementById('search__btn').click()
+      e.preventDefault();
+    }
+  });
+//$(document).ready(function () {
+//$('#dtBasicExample').DataTable();
+//$('.dataTables_length').addClass('bs-select');
+//});
+
+
+
+function check_form(){
+  dataOBJ = {'keyword':$('#following_keys').val()}
+  objstr = JSON.stringify(dataOBJ);
+  $.ajax({
+            url: 'http://www.googo.org:8001/kw_dm',
+            //url: 'http://www.choozmo.com:8888/qqreq',
+            dataType : 'json', // 預期從server接收的資料型態
+            contentType : 'application/json; charset=utf-8', // 要送到server的資料型態
+            type: 'post',
+            data: objstr,
+            success: function(suc_data) {
+                alert('hi im here')
+              },
+            //data:JSON.stringify({n1:"12",n2:"22"}),
+            error: function (error) {
+              alert('此網頁無法查詢!')
+              closeNav()
+            }
+        });
+
+let traffics;
+
+traffics = {
+    title: {
+        text: '世界人口总量',
+        subtext: '数据来自网络'
+    },
+    tooltip: {
+        trigger: 'axis',
+        axisPointer: {
+            type: 'shadow'
+        }
+    },
+    legend: {
+        data: ['2011年', '2012年']
+    },
+    grid: {
+        left: '3%',
+        right: '4%',
+        bottom: '3%',
+        containLabel: true
+    },
+    xAxis: {
+        type: 'value',
+        boundaryGap: [0, 0.01]
+    },
+    yAxis: {
+        type: 'category',
+        data: ['巴西', '印尼', '美国', '印度', '中国', '世界人口(万)']
+    },
+    series: [
+        {
+            name: '2011年',
+            type: 'bar',
+            data: [18203, 23489, 29034, 104970, 131744, 630230]
+        },
+        {
+            name: '2012年',
+            type: 'bar',
+            data: [19325, 23438, 31000, 121594, 134141, 681807]
+        }
+    ]
+};
+
+  traffics.setOption(traffics);
+      console.log(response.status);
+      console.log(response.statusText);
+      console.log(response.headers);
+      console.log(response.config);
+  
+  }
+</script>
+
+</body>
+
+    <footer class="footer text-center p-4 bg-white">
+    <div class="text-muted"> © 2021 Copyright: Googo Website Traffic</div>
+  </footer>
+</html>

+ 2 - 1
similar_web/main.py

@@ -107,7 +107,7 @@ async def index():
     return FileResponse('index.html')
 @app.get("/keywords")
 async def keyword():
-    return FileResponse('keywords.html')
+    return FileResponse('kw_new.html')
 @app.get("/echarts.min.js")
 async def index():
     return FileResponse('echarts.min.js')
@@ -127,6 +127,7 @@ async def get_domain_by_keyword(req:kw_req):
 @app.post("/dm")
 async def get_domain_data(req:q_req):
     jsdict = get_domain_data(req.domain_name)
+    print(jsdict)
     return JSONResponse(content=jsdict)