Switch to side-by-side view

--- a/OSSEval/OSSEval/utils.py
+++ b/OSSEval/OSSEval/utils.py
@@ -1,4 +1,7 @@
 from json import JSONEncoder
+from lxml import html
+import urllib2
+from apiclient.discovery import build
 
 class TrivialJSONEncoder(JSONEncoder):
     def default(self, o):
@@ -29,3 +32,36 @@
         except:
             return -1
         
+class SearchEngine():
+    @staticmethod
+    def search__engine_name():
+        return "Google"
+    
+    @staticmethod
+    def search_url(search_text, site_search=""):
+        if site_search == "":
+            return "https://www.google.com/?#q=" + search_text
+        else:
+            return "https://www.google.com/?#q=" + search_text + "+site%3A" + site_search
+
+    @staticmethod
+    def readable_query(search_text, site_search=""):
+        return search_text.replace("%3A", ":").replace("%20", " ").replace("%2B", "+") + ("" if site_search=="" else " site:" + site_search)
+
+    @staticmethod
+    def search_count(search_text, site_search=""):
+        '''
+        https://developers.google.com/custom-search/json-api/v1/reference/cse/list
+        exactTerms        string     Identifies a phrase that all documents in the search results must contain.
+        excludeTerms      string     Identifies a word or phrase that should not appear in any documents in the search results.
+        siteSearch        string     Specifies all search results should be pages from a given site.
+        siteSearchFilter  string     Controls whether to include or exclude results from the site named in the siteSearch parameter.
+        Acceptable values are:            "e": exclude            "i": include
+        '''
+        service = build("customsearch", "v1", developerKey="AIzaSyCAova46cAkHga_SZWTBqROdjoz1KcTlw8")
+        print search_text + " " + site_search
+        if site_search == "":
+            res = service.cse().list(q=search_text, cx='017576662512468239146:omuauf_lfve',).execute()
+        else:
+            res = service.cse().list(q=search_text, siteSearch=site_search, cx='017576662512468239146:omuauf_lfve',).execute()
+        return int(res['searchInformation']['totalResults'])