请找到以下代码:
from googleapiclient.discovery import build
my_api_key = "API$$$$$$"
my_cse_id = "Id $$$$$4"
def google_search(search_term, api_key, cse_id, **kwargs):
service = build("customsearch", "v1", developerKey=api_key)
res = service.cse().list(q=search_term, cx=cse_id, **kwargs).execute()
return res
result = google_search("Coffee", my_api_key, my_cse_id)
print(result)
~
我无法获得正确的输出:
它给我的网址就像端口':
u'width=device-width, initial-scale=1', u'handheldfriendly': u'true'}]}, u'snippet': u'Mar 31, 2016 ... Our weekly coffee hours continue Tuesday from 1-2pm in HFH 1132 with hot \ndrinks and crisp cookies sponsored by AppFolio, and a great\xa0...', u'htmlSnippet': u'Mar 31, 2016 <b>...</b> Our weekly <b>coffee</b> hours continue Tuesday from 1-2pm in HFH 1132 with hot <br>\ndrinks and crisp cookies sponsored by AppFolio, and a great ...', u'link': u'https://www.cs.ucsb.edu/news/events/hot-coffee-cool-research-tuesday-8', u'cacheId': u'O32sFI1uM_EJ'}, {u'kind': u'customsearch#result', u'title': u'Hot Coffee + Cool Research Tuesday | UCSB Computer Science', u'displayLink': u'www.cs.ucsb.edu', u'htmlTitle': u'Hot <b>Coffee</b> + Cool Research Tuesday | UCSB Computer Science', u'formattedUrl': u'https://www.cs.ucsb.edu/news/.../hot-coffee-cool-research-tuesday-3', u'htmlFormattedUrl': u'https://www.cs.ucsb.edu/news/.../hot-<b>coffee</b>-cool-research-tuesday-3', u'pagemap': {u'metatags': [{u'mobileoptimized': u'width', u'apple-mobile-web-app-capable': u'yes', u'viewport': u'width=device-width, initial-scale=1', u'handheldfriendly': u'true'}]}, u'snippet': u'Feb 23, 2016 ... Join us Tuesday from 1-2pm for our ongoing weekly coffee hours and short \nstudent presentations. Hot drinks and savory treats will be on offer\xa0...', u'htmlSnippet': u'Feb 23, 2016 <b>...</b> Join us Tuesday from 1-2pm for our ongoing weekly <b>coffee</b> hours and short <br>\nstudent presentations. Hot drinks and savory treats
但是我应该获得wiki.somthing
之类的网址或与咖啡相关的网址,该网址会显示在Google搜索的第一页上。
有人可以在这里帮助我吗?