From d31ade7a401d07162c93079e40db3fd7cb651af9 Mon Sep 17 00:00:00 2001 From: Jing Ling Date: Wed, 8 Jul 2020 16:48:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0GoogleAPISearch=E8=AF=A6?= =?UTF-8?q?=E7=BB=86=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/api.py | 10 ++++++---- modules/search/google_api.py | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config/api.py b/config/api.py index 82a93ce..d8b0c47 100644 --- a/config/api.py +++ b/config/api.py @@ -23,10 +23,12 @@ fofa_api_email = '' # fofa用户邮箱 fofa_api_key = '' # fofa用户key # Google可以免费注册获取API: -# https://developers.google.com/custom-search/v1/overview # 免费的API只能查询前100条结果 -google_api_key = '' # Google API搜索key -google_api_cx = '' # Google API搜索cx +# https://developers.google.com/custom-search/v1/overview#search_engine_id +# 创建自定义搜索引擎后需要在响应的控制面板上启用Search the entire web +google_api_id = '' # Google API自定义搜索引擎id +# https://developers.google.com/custom-search/v1/overview#api_key +google_api_key = '' # Google API自定义搜索key # https://api.passivetotal.org/api/docs/ riskiq_api_username = '' @@ -71,4 +73,4 @@ github_api_user = '' github_api_token = '' # obtain Cloudflare API key from https://dash.cloudflare.com/profile/api-tokens -cloudflare_api_token = '' \ No newline at end of file +cloudflare_api_token = '' diff --git a/modules/search/google_api.py b/modules/search/google_api.py index 8647a2d..86dd50e 100644 --- a/modules/search/google_api.py +++ b/modules/search/google_api.py @@ -12,7 +12,7 @@ class GoogleAPI(Search): self.addr = 'https://www.googleapis.com/customsearch/v1' self.delay = 1 self.key = api.google_api_key - self.cx = api.google_api_cx + self.id = api.google_api_id self.per_page_num = 10 # 每次只能请求10个结果 def search(self, domain, filtered_subdomain='', full_search=False): @@ -29,7 +29,7 @@ class GoogleAPI(Search): time.sleep(self.delay) self.header = self.get_header() self.proxy = self.get_proxy(self.source) - params = {'key': self.key, 'cx': self.cx, + params = {'key': self.key, 'cx': self.id, 'q': word, 'fields': 'items/link', 'start': self.page_num, 'num': self.per_page_num} resp = self.get(self.addr, params) @@ -50,7 +50,7 @@ class GoogleAPI(Search): """ 类执行入口 """ - if not self.check(self.cx, self.key): + if not self.check(self.id, self.key): return self.begin() self.search(self.domain, full_search=True) @@ -85,4 +85,4 @@ def do(domain): # 统一入口名字 方便多线程调用 if __name__ == '__main__': - do('example.com') + do('mi.com')