Source: site.view [edit]
Function name: searchDates
Arguments: query,dates
Description: Search for query from pages in dates
Page type: webl
Render function:  
Module: geneticFinance

Page source:

var dateRestrict = "&sort=date:r:" + dates;

var url = "https://www.googleapis.com/customsearch/v1?key=AIzaSyAO2RntyX5IUgDJmXO-i39U06wwIhKwdEE&cx=005856631263457543913:dc--shcxkz4&q=" 
      + Url_Encode(query) + dateRestrict;
var P = GetURL(url) ? nil;

var TextVal = fun(P, elt, fieldname, altfield, altalt)
   var E = Elem(P, fieldname) inside elt; 
   var res = (Str_Trim(Text(E[0])) ? "");
   if (res == "") and (altfield != nil) then
       E = Elem(P, altfield) inside elt; 
       res = (Str_Trim(Text(E[0])) ? "");
   end;
   if (res == "") and (altalt != nil) then
       E = Elem(P, altalt) inside elt; 
       res = (Str_Trim(Text(E[0])) ? "");
   end;
   res
end;


var news = [];
if (P != nil) then
   every item in Elem(P, "items") do

      news = news + [[. 
            pubdate = TextVal(P, item, "pub_date", "datemodified", nil),
            title = TextVal(P, item, "og:title", "headline", nil),
            sitename = TextVal(P, item, "og:site_name", "name", "displayLink"),
            link = TextVal(P, item, "link", "url", nil),
            snippet = TextVal(P, item, "snippet", "articlebody", nil),
            cacheId = TextVal(P, item, "cacheId", nil, nil)
          .] ]
  end
end;
news;