Search Engine Jsonp Interface

Source: Internet
Author: User

--------------------------------------- search Engine Jsonp interface ---------------------------------------------

Hint: the #content # in the URL is the keyword for the search

Google (google)

http://suggestqueries.google.com/complete/search?client=youtube&q= #content #&jsonp=window.google.ac.h

Callback: window.google.ac.h

WINDOW.GOOGLE.AC.H (["keywords", [[keywords], 0],["keyword lyrics", 0],["keyword parameters", 0],["keyword lyrics", 0],["keyword filter", 0],["keyword ranking", 0],["keyword query", 0],[keyword extraction algorithm, 0],[keyword planner in the following ways to help you create a new search network advertising series, 0],[keyword optimization, 0]],{"K": 1, "Q": "Uhab8zmjzjay-bacee_c0evduca"}])

 

Bing (Bing)

http://api.bing.com/qsonhs.aspx?type=cb&q= #content #&cb=window.bing.sug

Callback: Window.bing.sug

if (typeof Window.bing.sug = = ' function ') Window.bing.sug ({"as": {"Query": "keyword", "Fullresults": 0}}/* Pageview_ Candidate * *);

Baidu

http://suggestion.baidu.com/su?wd= #content #&cb=window.baidu.sug

Callback: Window.baidu.sug

Window.baidu.sug ({q: "keywords", p:false,s:["keyword search rankings", "keywords how to optimize", "Keyword query tool", "keyword promotion", "keyword optimization", "keyword ranking", "Keyword English", "keyword mining", " Keyword query "," Keyword Search "]});

Good Search (SO)

https://sug.so.360.cn/suggest?encodein=utf-8&encodeout=utf-8&format=json&word= #content #& Callback=window.so.sug

Callback:Window.so.sug

Window.so.sug ({"Query": "keywords", "result": [{"word": "keyword query"},{"word": "keyword Tool"},{"word": Keyword query tool},{"word": "Keyword Mining"},{ "word": "Keyword search"},{"word": "keywords English"},{"word:" What is the keyword "},{word: Keyword ad},{word: Keyword analysis},{word: keyword Planner"} "," Key word " Version ":" B "," Rec ":" "});

Sogou (Sogou)

https://www.sogou.com/suggnew/ajajjson?type=web&key= #content #

Callback:Window.sogou.sug

WINDOW.SOGOU.SUG ([keywords], [keyword query], "keyword search", keyword optimization "," keyword planner "," keyword query lol "," What does the keyword mean "," keyword search tool "," keyword advertising picture "," keyword ranking query ", "Keyword Builder"],["0;0;0;0", "1;0;0;0", "2;0;0;0", "3;0;0;0", "4;0;0;0", "5;0;0;0", "6;0;0;0", "7;0;0;0", "8;0;0;0", "9;0;0;0" ],["," "," "," "," "," "," "," "," "," "", "", ""],["0"], "", "Suglabid_1"],-1);

Taobao (Taobao)

https://suggest.taobao.com/sug?code=utf-8&q= #content #&callback=window.taobao.sug

Callback:Window.taobao.sug

Window.taobao.sug ({"Result": ["Keyword Promotion", "204"],["keyword seo", "198"],["keyword website", "182"],["keyword search", "119"],["keyword Software", "44"],[ "Keywords Home", "50"],["keyword included", "35"],["keyword Acquisition", "16"],["keyword Collector", "10"],["website keyword", "180"]})

--------------------------------------- How to use the search suggestions ---------------------------------------------

In the case of Baidu, the API returns JSONP data, and Jsonp is a way of cross-domain access. Because the JavaScript code returned by the server can be referenced directly, the server's data can be obtained indirectly by means of a callback function.

The following is an example of a callback search recommendation that Window.baidu.sug returns a JSON object

        <script type= "Text/javascript" >
            window.onload = function () {
                
                //Assembly query address
                var sugurl = "http:// suggestion.baidu.com/su?wd= #content #&cb=window.baidu.sug ";
                var content = "keywords";
                Sugurl = Sugurl.replace ("#content #", content);

                Define callback function
                Window.baidu = {
                    sug:function (JSON) {
                        console.log (JSON)
                    }
                }

                ///Add JS script
                dynamically var script = document.createelement ("script");
                SCRIPT.SRC = Sugurl;
                document.getElementsByTagName ("Head") [0].appendchild (script);

            }
        </script>

The result of the console printing: If you want to save the result in an array of strings, you need only var arr = json.s.


The above is reproduced content, we can also use Ajax to obtain the Baidu search box data, but also using the jsonp of the Cross-domain Way

Take Baidu as an example:

First of all, we have to find the interface of Baidu search box, get the data inside, and then upload to our own page, get the interface is [JavaScript] view plain copy print? HTTPS://SP0.BAIDU.COM/5A1FAZU8AA54NXGKO9WTANF6HHY/SU;

How to get the interface of Baidu. Open Baidu homepage, press F12 Open developer tools, in the Baidu search box casually input fields, in the network crawl to the interface;

After the crawl, you can do the operation, I used the jquery write code;

[HTML] view plain copy print? <body> Please enter: <input list= "languagelist" id= "value" type= "text"/> <datalist "id=" > < /datalist> </body>



[JavaScript]   View plain  copy     print <script>    & nbsp;  /* sets up the listener event, enters the contents into the input box, and when the keyboard button bounces, passes the input as a parameter into the function info */       $ ("# Value "). Bind (" KeyUp ", Function (event) {           /* when the keyboard presses the up and down key , do not listen, otherwise it will conflict with the KeyUp event */           if (event.keycode ==  38 | | &NBSP;EVENT.KEYCODE&NBSP;==&NBSP;40) {  

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.