index3.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Googo Website Traffic</title>
  8. <!-- Font Awesome -->
  9. <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet" />
  10. <!-- Google Fonts -->
  11. <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
  12. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
  13. integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  14. <!-- MDB -->
  15. <link href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/3.3.0/mdb.min.css" rel="stylesheet" />
  16. <link rel="stylesheet" href="https://unpkg.com/js-datepicker/dist/datepicker.min.css">
  17. <link rel="stylesheet" type="text/css" href="reset.css">
  18. <link rel="stylesheet" type="text/css" href="main.css">
  19. <!-- MDB -->
  20. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/3.3.0/mdb.min.js"></script>
  21. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  22. <script src="echarts.min.js"></script>
  23. <style>
  24. body {
  25. font-family: 'Lato', sans-serif;
  26. }
  27. #seo_string a {
  28. background-color: #3845bb;
  29. border: none;
  30. border-radius: 5rem;
  31. outline: none;
  32. color: white;
  33. font-size: 1rem;
  34. padding: .2rem .6rem;
  35. margin: .2rem;
  36. }
  37. .overlay {
  38. height: 100%;
  39. width: 100%;
  40. display: none;
  41. position: fixed;
  42. z-index: 1;
  43. top: 0;
  44. left: 0;
  45. background-color: rgb(0, 0, 0);
  46. background-color: rgba(0, 0, 0, 0.6);
  47. }
  48. .overlay-content {
  49. position: relative;
  50. top: 25%;
  51. width: 100%;
  52. text-align: center;
  53. margin-top: 30px;
  54. }
  55. .overlay a {
  56. padding: 8px;
  57. text-decoration: none;
  58. font-size: 36px;
  59. color: #818181;
  60. display: block;
  61. transition: 0.3s;
  62. }
  63. .overlay a:hover,
  64. .overlay a:focus {
  65. color: #f1f1f1;
  66. }
  67. .overlay .closebtn {
  68. position: absolute;
  69. top: 20px;
  70. right: 45px;
  71. font-size: 60px;
  72. }
  73. @media screen and (max-height: 450px) {
  74. .overlay a {
  75. font-size: 20px
  76. }
  77. .overlay .closebtn {
  78. font-size: 40px;
  79. top: 15px;
  80. right: 35px;
  81. }
  82. }
  83. </style>
  84. </head>
  85. <body class="color__grey">
  86. <div id="myNav" class="overlay">
  87. <div class="overlay-content">
  88. <a href="#">載入資料中,請稍候</a>
  89. </div>
  90. </div>
  91. <!-- Navbar -->
  92. <nav class="navbar navbar-expand-lg navbar-light bg-white">
  93. <!-- Container wrapper -->
  94. <div class="container-fluid">
  95. <!-- Navbar brand -->
  96. <a class="navbar-brand" href="#">Google Keyword Search Volume</a>
  97. <!-- Toggle button -->
  98. <button class="navbar-toggler" type="button" data-mdb-toggle="collapse" data-mdb-target="#navbarSupportedContent"
  99. aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  100. <i class="fas fa-bars text-light"></i>
  101. </button>
  102. <!-- Collapsible wrapper -->
  103. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  104. <!-- Left links -->
  105. <ul class="navbar-nav me-auto d-flex flex-row mt-3 mt-lg-0">
  106. <li class="nav-item text-center mx-2 mx-lg-1">
  107. <a class="nav-link active" aria-current="page" href="index.html">
  108. <div>
  109. <i class="fas fa-home fa-lg mb-1"></i>
  110. </div>
  111. 首頁
  112. </a>
  113. </li>
  114. <!--
  115. <li class="nav-item text-center mx-2 mx-lg-1">m
  116. <a class="nav-link" href="http://news.google.com">
  117. <div>
  118. <i class="fas fa-globe-americas fa-lg mb-1"></i>
  119. </div>
  120. 新聞
  121. </a>
  122. </li>
  123. <li class="nav-item text-center mx-2 mx-lg-1">
  124. <a class="nav-link" href="keywords.html">
  125. <div>
  126. <i class="fab fa-korvue fa-lg mb-1"></i>
  127. </div>
  128. 關鍵字
  129. </a>
  130. </li>
  131. -->
  132. </ul>
  133. <!-- Right links -->
  134. </div>
  135. <!-- Collapsible wrapper -->
  136. </div>
  137. <!-- Container wrapper -->
  138. </nav>
  139. <!-- Navbar -->
  140. <div class="container">
  141. <div class="row">
  142. <!-- <div class="col-1 col-lg-1"></div> -->
  143. <div class="col-12 col-12">
  144. <!-- Search form -->
  145. <form id="searchform" class="d-flex input-group search__form">
  146. <input type="search" class="form-control search__bar" placeholder="在此輸入關鍵字" aria-label="Domain Name"
  147. id="search_query" />
  148. <button class="btn btn-primary search__btn" type="button" data-mdb-ripple-color="dark" id="search__btn">
  149. 查詢
  150. </button>
  151. </form>
  152. <h3 class="h3 text-center" id="sitename">Website Traffic</h3>
  153. <div class="card card__grback mb-4">
  154. <div class="card-body card__left">
  155. <!-- 根據搜尋內容顯示網站標題及網站內容簡介 -->
  156. <h5 class="card-title card__url" id="sitetitle"><i class="fas fa-chart-bar card__url__icon"></i>Example.com
  157. </h5>
  158. <p class="card-text card__intro" id="descriptions">
  159. Lorem ipsum dolor sit amet consectetur adipisicing elit. Ut ipsa totam maxime pariatur iure
  160. suscipit nihil possimus deserunt esse blanditiis. Quidem aliquid, voluptas quae tenetur quaerat
  161. iure explicabo repellat ad.
  162. </p>
  163. <!-- <a href="#" class="btn btn-primary" id="globalrank2"></a> -->
  164. </div>
  165. </div>
  166. <div class="text-muted mb-2 border-bottom">關鍵字搜尋量</div>
  167. <div class="row g-5 mb-3">
  168. <div class="col-sm-4">
  169. <div class="card p-3">
  170. <div class="card-body text-center">
  171. <h5 class="card-title card__rank__title mb-2">平均月搜量</h5>
  172. <p class="card-text">
  173. </p>
  174. <span href="#" class="rank__mark"># <strong id="globalrank" class="rank_num"></strong></span>
  175. </div>
  176. </div>
  177. </div>
  178. <div class="col-sm-4">
  179. <div class="card p-3">
  180. <div class="card-body text-center">
  181. <h5 class="card-title card__rank__title mb-2">平均月搜量</h5>
  182. <p class="card-text">
  183. </p>
  184. <span href="#" class="rank__mark"># <strong id="countryrank" class="rank_num"></strong></span>
  185. </div>
  186. </div>
  187. </div>
  188. <div class="col-sm-4">
  189. <div class="card p-3">
  190. <div class="card-body text-center">
  191. <h5 class="card-title card__rank__title mb-2"><i class="fas fa-tags"></i>平均月搜量</h5>
  192. <p class="card-text card__rank__cat" id="category">
  193. </p>
  194. </div>
  195. </div>
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. <div class="card card__notHover">
  202. <div id="main" class="chart"></div>
  203. </div>
  204. <footer class="footer text-center p-4 bg-white">
  205. <div class="text-muted"> © 2021 Copyright: Googo Website Traffic</div>
  206. </footer>
  207. <script src="https://code.jquery.com/jquery-3.6.0.min.js"
  208. integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
  209. <script src="https://unpkg.com/js-datepicker"></script>
  210. <script>
  211. function openNav() {
  212. document.getElementById("myNav").style.display = "block";
  213. }
  214. function closeNav() {
  215. document.getElementById("myNav").style.display = "none";
  216. }
  217. const input = document.getElementById("search_query");
  218. const search__btn = document.getElementById("search__btn");
  219. const btn__benefit = document.querySelectorAll(".btn__benefit");
  220. $('.sub__date').click(function (e) {
  221. e.preventDefault();
  222. console.log(picker_end.getRange());
  223. });
  224. search__btn.addEventListener("click", function (e) {
  225. // openNav()
  226. e.preventDefault();
  227. check_form();
  228. })
  229. btn__benefit.forEach((item, i) => {
  230. item.addEventListener("click", function () {
  231. item.toggleClass('active');
  232. })
  233. });
  234. $('#search_query').keydown(function (e) {
  235. //
  236. if (event.keyCode == 13) {
  237. document.getElementById('search__btn').click()
  238. e.preventDefault();
  239. }
  240. });
  241. const myChart = echarts.init(document.getElementById('main'));
  242. let option;
  243. function check_form() {
  244. const sitename = document.getElementById('sitename');
  245. const sitetitle = document.getElementById('sitetitle');
  246. const descriptions = document.getElementById('descriptions');
  247. const globalrank = document.getElementById('globalrank');
  248. const countryrank = document.getElementById('countryrank');
  249. const category = document.getElementById('category');
  250. response = ''
  251. dataOBJ = { 'keyword': $('#search_query').val() }
  252. // alert(dataOBJ)
  253. objstr = JSON.stringify(dataOBJ);
  254. console.log(objstr);
  255. // $.get("http://api.ptt.cx:8080/keyword/"+$('#search_query').val(), function (result) {
  256. $.get("http://google.cmm.ai/keyword/"+$('#search_query').val(), function (result) {
  257. console.log(result);
  258. $('#globalrank').html(result.msearch);
  259. $('#countryrank').html(result.msearch);
  260. $('#category').html(result.msearch);
  261. $('#sitetitle').html($('#search_query').val());
  262. $('#descriptions').html("關鍵字的搜尋熱度。數字為每個月的平均搜尋量。資料來源為Google廣告系統。");
  263. key_ary = [];
  264. val_ary = [];
  265. for(var i = 0; i < result.months.length; i++) {
  266. var obj = result.months[i];
  267. key_ary.push(obj.month);
  268. val_ary.push(obj.vol);
  269. }
  270. option = {
  271. tooltip: {
  272. trigger: 'axis'
  273. },
  274. xAxis: {
  275. type: 'category',
  276. boundaryGap: false,
  277. data: key_ary
  278. },
  279. yAxis: {
  280. type: 'value'
  281. },
  282. series: [{
  283. data: val_ary,
  284. type: 'line',
  285. areaStyle: {},
  286. }]
  287. };
  288. myChart.setOption(option);
  289. // alert(result.competition)
  290. // alert(result.msearch);
  291. // for (let i = 0; i < result.length; i++) {
  292. // seoStr = seoStr + '<a class=tag>' + result[i].kw + '</a>'
  293. // }
  294. // seoStr = seoStr.substring(0, seoStr.length - 1);
  295. // $('#seo_string').html(seoStr)
  296. });
  297. /*
  298. $.ajax({
  299. url: 'http://www.googo.org:8001/kw_dm',
  300. //url: 'http://www.choozmo.com:8888/qqreq',
  301. dataType: 'json', // 預期從server接收的資料型態
  302. contentType: 'application/json; charset=utf-8', // 要送到server的資料型態
  303. type: 'post',
  304. data: objstr,
  305. success: function (suc_data) {
  306. response = suc_data
  307. sitename.textContent = response.SiteName;
  308. descriptions.textContent = response.Description;
  309. globalrank.textContent = response.GlobalRank;
  310. sitetitle.textContent = response.Title;
  311. countryrank.textContent = response.CountryRank;
  312. category.textContent = response.Category;
  313. if (response.totalVisits != -1) {
  314. $('#maxflow').html(response.totalVisits+'人次')
  315. }
  316. else {
  317. $('#maxflow').html("N/A")
  318. }
  319. key_ary = [];
  320. val_ary = [];
  321. for (const [key, value] of Object.entries(response.EstimatedMonthlyVisits)) {
  322. key_ary.push(key);
  323. val_ary.push(value);
  324. }
  325. option = {
  326. tooltip: {
  327. trigger: 'axis'
  328. },
  329. xAxis: {
  330. type: 'category',
  331. boundaryGap: false,
  332. data: key_ary
  333. },
  334. yAxis: {
  335. type: 'value'
  336. },
  337. series: [{
  338. data: val_ary,
  339. type: 'line',
  340. areaStyle: {},
  341. }]
  342. };
  343. myChart.setOption(option);
  344. closeNav()
  345. },
  346. //data:JSON.stringify({n1:"12",n2:"22"}),
  347. error: function (error) {
  348. alert('此網頁無法查詢!')
  349. closeNav()
  350. }
  351. });
  352. */
  353. }
  354. </script>
  355. </body>
  356. </html>