|
a/OSSEval/OSSEval/utils.py |
|
b/OSSEval/OSSEval/utils.py |
1 |
from json import JSONEncoder
|
1 |
from json import JSONEncoder
|
2 |
from lxml import html
|
2 |
from lxml import html
|
3 |
import urllib2
|
3 |
import urllib2
|
4 |
from apiclient.discovery import build
|
4 |
from apiclient.discovery import build
|
5 |
from apiclient.errors import HttpError
|
5 |
from apiclient.errors import HttpError
|
|
|
6 |
import OSSEval
|
|
|
7 |
|
|
|
8 |
class Configuration():
|
|
|
9 |
google_developerKey = OSSEval.google_developerKey
|
6 |
|
10 |
|
7 |
class TrivialJSONEncoder(JSONEncoder):
|
11 |
class TrivialJSONEncoder(JSONEncoder):
|
8 |
def default(self, o):
|
12 |
def default(self, o):
|
9 |
return o.__dict__
|
13 |
return o.__dict__
|
10 |
|
14 |
|
|
... |
|
... |
79 |
siteSearch string Specifies all search results should be pages from a given site.
|
83 |
siteSearch string Specifies all search results should be pages from a given site.
|
80 |
siteSearchFilter string Controls whether to include or exclude results from the site named in the siteSearch parameter.
|
84 |
siteSearchFilter string Controls whether to include or exclude results from the site named in the siteSearch parameter.
|
81 |
Acceptable values are: "e": exclude "i": include
|
85 |
Acceptable values are: "e": exclude "i": include
|
82 |
'''
|
86 |
'''
|
83 |
try:
|
87 |
try:
|
84 |
service = build("customsearch", "v1", developerKey="AIzaSyCAova46cAkHga_SZWTBqROdjoz1KcTlw8")
|
88 |
service = build("customsearch", "v1", developerKey=OSSEval.google_developerKey)
|
85 |
total = 0
|
89 |
total = 0
|
86 |
if len(sites) == 0:
|
90 |
if len(sites) == 0:
|
87 |
res = service.cse().list(q=search_text, cx='017576662512468239146:omuauf_lfve',).execute()
|
91 |
res = service.cse().list(q=search_text, cx='017576662512468239146:omuauf_lfve',).execute()
|
88 |
total = int(res['searchInformation']['totalResults'])
|
92 |
total = int(res['searchInformation']['totalResults'])
|
89 |
else:
|
93 |
else:
|