Viết dòng code Python để tương tác với API của Google
- User
Viết dòng code Python để tương tác với API của Google
- Assistant
Đây là dòng code Python dùng để tương tác với API tìm kiếm của Google:
from googleapiclient.discovery import build import pprint
chia_khoa_api = "Chìa khoá API của Google" id_cong_cu = "ID của công cụ tìm kiếm của Google"
// Tạo ra hàm để tương tác với API def tim_tren_google(tu_khoa, chia_khoa_api, id_cong_cu, **kwargs): service = build("customsearch", "v1", developerKey=chia_khoa_api) res = service.cse().list(q=tu_khoa, cx=id_cong_cu, **kwargs).execute() return res['items']
// Dùng hàm tim_tren_google ket_qua = google_search("bài tập toán 12 site:hocmai.vn", chia_khoa_api, id_cong_cu, num=10)
// In ra kết quả for muc in ket_qua: pprint.pprint(muc)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.