1024programmer Java JS implementation of methods to obtain keywords from Baidu, Google, soso, sogou

JS implementation of methods to obtain keywords from Baidu, Google, soso, sogou

The example in this article describes the method of JS implementation to obtain keywords from Baidu, Google, soso, and sogou. Share it with everyone for your reference, the details are as follows:

 /*Get the user, which keyword is used to access the page, and you can add SOGOU, SOSO, Youdao and other search engines by yourself*/
 var refer=document.referrer;
 var sosuo=refer.split(".")[1];
 var grep=null;
 var str=null;
 var keyword=null;
 switch(sosuo){
  case "baidu":
   grep=/wd\=.*\&/i;
   str=refer.match(grep)
   keyword=str.toString().split("=")[1].split("&")[0];
   console.log(decodeURIComponent(keyword));
  break;
  case "google":
   grep=/&q\=.*\&/i;
   str=refer.match(grep)
   keyword=str.toString().split("&")[1].split("=")[1];
   console.log(decodeURIComponent(keyword));
  break;
 }

 

Readers who are interested in more Javascript-related content can check out the special topics of this site: “Summary of Javascript Search Algorithm Techniques”, “Summary of Javascript Data Structure and Algorithm Techniques”, “Summary of Javascript Traversal Algorithms and Techniques”, “JSON in Javascript” Summary of Operation Skills”, “Summary of Javascript Switching Special Effects and Techniques”, “Summary of Javascript Animation Special Effects and Techniques”, “Summary of Javascript Errors and Debugging Techniques” and “Summary of Javascript Mathematical Operation Usage”

I hope this article will be helpful to everyone in Javascript programming.

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/js-implementation-of-methods-to-obtain-keywords-from-baidu-google-soso-sogou/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: 34331943@QQ.com

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索