简体   繁体   中英

Can I get Google Ads from Google Custom Search API for requested query?

I would like to get Google Ads for a specific search term using the Google Custom Search API. Getting search results works fine (see code below) using the GET-command but Ads are not included in the response I think.

Is there a way to get Ads from Google for a specific search term using the Custom Search API? Or maybe with another API?

I would be very thankful for help, thanks!

Code for getting search results:

function requestSearchResult() {
    jQuery.get("https://www.googleapis.com/customsearch/v1/", {
            q: SearchTerm,
            cx: "01042***5fgs",
            key: "AL***Xra",
        },
        function(items, status) {
            document.getElementById("content").innerHTML += "<a href=\"" + items.items[0].link + "\">" + items.items[0].htmlTitle + "</a>";
            document.getElementById("content").innerHTML += "<br>" + items.items[0].displayLink;
            document.getElementById("content").innerHTML += "<br>" + items.items[0].htmlSnippet;
            document.getElementById('content').innerHTML += "<br>" + '<img src="' + items.items[0].pagemap.cse_thumbnail[0].src + '" alt="text mode" />';
            ...
            ...
        });

The Custom Search API does not provide ads.

If you want search and ads consider using the Custom Search Element which does both: https://developers.google.com/custom-search/docs/element

Or sign up for Custom Search Ads: https://developers.google.com/custom-search-ads/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM