Thursday, 15 March 2012

api - A Google apps javascript function to return the number of hits for a search term -


How do I go about applying a Google App Script to return the number of hits from Google Search? Especially I have a Google spreadsheet where the formula in cell A2 is = GOOGLEHITS (A1) .

I have found:

  function GoogleHits (keyword) {return ??? ("\" "+ Keyword +" \ ""); }   

Want to know more about "???"

Let's say that you are searching for a way to drag the result count First of a Google search page, find out where that page is in Firefox, for example, you can use such an inspector.

screenshot

About parsing information from web pages The last questions are, and it has been done very easily using URLFH and XML Services.

  • GoogleHits function can be used as a custom code from the li>>

    code

    sheet. The test function calls it directly.

      function test_GoogleHits () {function testing (keyword) {Logger.log (keyword + ':' + GoogleHits (keyword)); } Examination ('googlehits'); Test ('pizza'); Test ('Today's Season'); } GoogleHits (keywords) function {var target = "https://www.google.ca/search?q="+encodeURI(keywords"); Var pagetext = UrlFetchApp.fetch (target) .getContentText (); Var page doc = xml.parse (pagetast, true); Var contentDiv = getDivById (pageDoc.getElement). Body, 'resultStats'); Remove the return image (contentDiv.Text); } Remove the object (str) {var num = ""; Var inNum = false; (Var i = 0; i & lt; str.length; i ++) for {var c = str.charAt (i); If (C> = '0' & amp; amp;; c; & lt; = '9') {if (! InNum) inNum = true; Number + = c; } And if (c! == ',') {If (inum) break; }} Return Parasont (num); }    

  • No comments:

    Post a Comment