Php obtains website keywords and supports Baidu, Google, and other search engines.

Source: Internet
Author: User
Obtain the website keywords. support baidu, Google, soso, Yahoo, and other search engines. [code] php code view source


Print?

01
02 $ _ SERVER ['http _ referer'] = 'http: // www.baidu.com/s? Wd = http://www.iiwnet.com ';
03 Echo save_www_iiwnet_com_keyword ('http: // www.baidu.com/s? Wd = http://www.iiwnet.com ', 'http: // www.baidu.com/s? Wd = http://www.iiwnet.com ');
04 Function save_www_iiwnet_com_keyword ($ domain, $ path ){
05 If (strpos ($ domain, 'Google .com.tw ')! = False & preg_match ('/q = ([^ &] *)/I', $ path, $ regs )){
06 $ Searchengine = 'Google TAIWAN ';
07 $ Keywords = urldecode ($ regs [1]); // google taiwan
08 }
09 If (strpos ($ domain, 'google. cn ')! = False & preg_match ('/q = ([^ &] *)/I', $ path, $ regs )){
10 $ Searchengine = 'Google China ';
11 $ Keywords = urldecode ($ regs [1]); // google china
12 }
13 If (strpos ($ domain, 'google. com ')! = False & preg_match ('/q = ([^ &] *)/I', $ path, $ regs )){
14 $ Searchengine = 'Google ';
15 $ Keywords = urldecode ($ regs [1]); // google
16 } Elseif (strpos ($ domain, 'Baidu .')! = False & preg_match ('/wd = ([^ &] *)/I', $ path, $ regs )){
17 $ Searchengine = 'baidu ';
18 $ Keywords = urldecode ($ regs [1]); // baidu
19 } Elseif (strpos ($ domain, 'Baidu .')! = False & preg_match ('/word = ([^ &] *)/I', $ path, $ regs )){
20 $ Searchengine = 'baidu ';
21 $ Keywords = urldecode ($ regs [1]); // baidu
22 } Elseif (strpos ($ domain, '2017 .vnet.cn ')! = False & preg_match ('/kw = ([^ &] *)/I', $ path, $ regs )){
23 $ Searchengine = 'ct114 ';
24 $ Keywords = urldecode ($ regs [1]); // ct114
25 } Elseif (strpos ($ domain, 'iask. com ')! = False & preg_match ('/k = ([^ &] *)/I', $ path, $ regs )){
26 $ Searchengine = 'iask ';
27 $ Keywords = urldecode ($ regs [1]); // iask
28 } Elseif (strpos ($ domain, 'soso. com ')! = False & preg_match ('/w = ([^ &] *)/I', $ path, $ regs )){
29 $ Searchengine = 'soso ';
30 $ Keywords = urldecode ($ regs [1]); // soso
31 } Elseif (strpos ($ domain, 'sogou. com ')! = False & preg_match ('/query = ([^ &] *)/I', $ path, $ regs )){
32 $ Searchengine = 'sogou ';
33 $ Keywords = urldecode ($ regs [1]); // sogou
34 } Elseif (strpos ($ domain, 'So .163.com ')! = False & preg_match ('/q = ([^ &] *)/I', $ path, $ regs )){
35 $ Searchengine = 'deletease ';
36 $ Keywords = urldecode ($ regs [1]); // netease
37 } Elseif (strpos ($ domain, 'yodao. com ')! = False & preg_match ('/q = ([^ &] *)/I', $ path, $ regs )){
38 $ Searchengine = 'yodao ';
39 $ Keywords = urldecode ($ regs [1]); // yodao
40 } Elseif (strpos ($ domain, 'zhongsou. com ')! = False & preg_match ('/word = ([^ &] *)/I', $ path, $ regs )){
41 $ Searchengine = 'zhongsou ';
42 $ Keywords = urldecode ($ regs [1]); // zhongsou
43 } Elseif (strpos ($ domain, 'search .tom.com ')! = False & preg_match ('/w = ([^ &] *)/I', $ path, $ regs )){
44 $ Searchengine = 'Tom ';
45 $ Keywords = urldecode ($ regs [1]); // tom
46 } Elseif (strpos ($ domain, 'Live. com ')! = False & preg_match ('/q = ([^ &] *)/I', $ path, $ regs )){
47 $ Searchengine = 'mslive ';
48 $ Keywords = urldecode ($ regs [1]); // MSLIVE
49 } Elseif (strpos ($ domain, 'tw .search.yahoo.com ')! = False & preg_match ('/p = ([^ &] *)/I', $ path, $ regs )){
50 $ Searchengine = 'Yahoo TAIWAN ';
51 $ Keywords = urldecode ($ regs [1]); // yahoo taiwan
52 } Elseif (strpos ($ domain, 'CN. yahoo .')! = False & preg_match ('/p = ([^ &] *)/I', $ path, $ regs )){
53 $ Searchengine = 'Yahoo China ';
54 $ Keywords = urldecode ($ regs [1]); // yahoo china
55 } Elseif (strpos ($ domain, 'Yahoo .')! = False & preg_match ('/p = ([^ &] *)/I', $ path, $ regs )){
56 $ Searchengine = 'Yahoo ';
57 $ Keywords = urldecode ($ regs [1]); // yahoo
58 } Elseif (strpos ($ domain, 'MSN .com.tw ')! = False & preg_match ('/q = ([^ &] *)/I', $ path, $ regs )){
59 $ Searchengine = 'MSN TAIWAN ';
60 $ Keywords = urldecode ($ regs [1]); // msn taiwan
61 } Elseif (strpos ($ domain, 'MSN .com.cn ')! = False & preg_match ('/q = ([^ &] *)/I', $ path, $ regs )){
62 $ Searchengine = 'MSN China ';
63 $ Keywords = urldecode ($ regs [1]); // msn china
64 } Elseif (strpos ($ domain, 'MSN. com ')! = False & preg_match ('/q = ([^ &] *)/I', $ path, $ regs )){
65 $ Searchengine = 'MSN ';
66 $ Keywords = urldecode ($ regs [1]); // msn
67 }
68 Return $ keywords;
69 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.