Explorar el Código

Merge branch 'master' of http://git.choozmo.com:3000/choozmo/kw_tools into master

Your Name hace 3 años
padre
commit
986540fa67
Se han modificado 2 ficheros con 26 adiciones y 14 borrados
  1. 15 5
      similar_web/index2.html
  2. 11 9
      similar_web/main.py

+ 15 - 5
similar_web/index2.html

@@ -156,7 +156,7 @@
       <div class="col-12 col-12">
         <!-- Search form  -->
         <form id="searchform" class="d-flex input-group search__form">
-          <input type="search" class="form-control search__bar" placeholder="在此輸入網址" aria-label="Domain Name"
+          <input type="search" class="form-control search__bar" placeholder="在此輸入關鍵字" aria-label="Domain Name"
             id="search_query" />
           <button class="btn btn-primary search__btn" type="button" data-mdb-ripple-color="dark" id="search__btn">
             查詢
@@ -248,7 +248,7 @@
             <div class="card card__notHover" style="line-height:28px">
               <!--<div id="bar" class="chart"></div>-->
               <div id='seo_string'>
-<a class="tag">sdv</a>
+                <a class="tag">sdv</a>
               </div>
             </div>
           </div>
@@ -333,7 +333,6 @@
         type: 'post',
         data: objstr,
         success: function (suc_data) {
-
           response = suc_data
           sitename.textContent = response.SiteName;
           descriptions.textContent = response.Description;
@@ -341,7 +340,13 @@
           sitetitle.textContent = response.Title;
           countryrank.textContent = response.CountryRank;
           category.textContent = response.Category;
-          $('#maxflow').html(response.totalVisits)
+          if (response.totalVisits != -1) {
+            $('#maxflow').html(response.totalVisits+'人次')
+          }
+          else {
+            $('#maxflow').html("N/A")
+          }
+
           key_ary = [];
           val_ary = [];
 
@@ -351,6 +356,10 @@
           }
 
           option = {
+
+            tooltip: {
+              trigger: 'axis'
+            },
             xAxis: {
               type: 'category',
               boundaryGap: false,
@@ -362,7 +371,8 @@
             series: [{
               data: val_ary,
               type: 'line',
-              areaStyle: {}
+              areaStyle: {},
+
             }]
           };
           myChart.setOption(option);

+ 11 - 9
similar_web/main.py

@@ -55,7 +55,7 @@ def get_domain_data(raw_domain):
     return jsdict
 
 def domain_filter(url_array):
-    exclude_list = ['facebook','youtube','twitter','linkedin','instagram']
+    exclude_list = ['facebook','youtube','twitter','linkedin','instagram','wiki']
     list_filted = []
     for url in url_array:
         a_social_media = False
@@ -112,36 +112,38 @@ async def get_domain_by_keyword(req:kw_req):
         domain_name='http://'+domain_name
     domain_name = domain_name.replace('%3A',':')
     domain_name = domain_name.replace('%2F','/')
-    print(domain_name)
+
     querystring = {"website":domain_name}
     db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
-    
-    statement = 'SELECT * FROM storage_similar_web where SiteName ="'+ raw_domain+'"'
+
+    statement = 'SELECT * FROM storage_similar_web where SiteName ="'+ domain_name+'"'
     jsdict = None
     for row in db.query(statement):
         jsdict = {'SiteName':row['SiteName'],'Description':row['Description'],'GlobalRank':row['GlobalRank']
-        ,'Title':row['Title'],'Category':row['Category'],'CountryRank':row['CountryRank'],'EstimatedMonthlyVisits':eval(row['EstimatedMonthlyVisits'])
-        ,'totalVisits':row['totalVisits']}
+            ,'Title':row['Title'],'Category':row['Category'],'CountryRank':row['CountryRank'],'EstimatedMonthlyVisits':eval(row['EstimatedMonthlyVisits'])
+            ,'totalVisits':row['totalVisits']}
 
     if jsdict==None:
         headers = {"x-rapidapi-key": "6dd30886e0msh7aefc9a0a794398p1896f2jsn275c45475609",
             "x-rapidapi-host": "similarweb2.p.rapidapi.com"}
         response = requests.request("GET", url, headers=headers, params=querystring)
+        print(response.text)
         js=json.loads(response.text)
-        print(js)
+        
         jsdict={'SiteName':js['name'],'Description':js['siteDescription'],'GlobalRank':js['globalRank'],'Title':js['name'],'Category':js['categoryRank']['taxonomy'],'CountryRank':js['countryRank']['rank']}
         url = "https://similarweb2.p.rapidapi.com/trafficoverview"
         querystring = {"website":domain_name}
         time.sleep(5)
         try:
             response = requests.request("GET", url, headers=headers, params=querystring)
+            print(response.text)
             js2=json.loads(response.text)
-            print(js2)
+            
             jsdict['totalVisits'] = js2['engagement']['totalVisits']
             jsdict['EstimatedMonthlyVisits']=js2['monthlyVisitsEstimate']
         except:
             jsdict['totalVisits'] = -1
-            jsdict['EstimatedMonthlyVisits'] = 'no data'
+            jsdict['EstimatedMonthlyVisits'] = '[]'
 
         log_table = db['storage_similar_web']
         log_table.insert({'SiteName':raw_domain,'Description':jsdict['Description'],'GlobalRank':jsdict['GlobalRank']