添加GoogleAPISearch详细说明

This commit is contained in:
Jing Ling
2020-07-08 16:48:14 +08:00
parent 8880f13157
commit d31ade7a40
2 changed files with 10 additions and 8 deletions
+5 -3
View File
@@ -23,10 +23,12 @@ fofa_api_email = '' # fofa用户邮箱
fofa_api_key = '' # fofa用户key fofa_api_key = '' # fofa用户key
# Google可以免费注册获取API: # Google可以免费注册获取API:
# https://developers.google.com/custom-search/v1/overview
# 免费的API只能查询前100条结果 # 免费的API只能查询前100条结果
google_api_key = '' # Google API搜索key # https://developers.google.com/custom-search/v1/overview#search_engine_id
google_api_cx = '' # Google API搜索cx # 创建自定义搜索引擎后需要在响应的控制面板上启用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/ # https://api.passivetotal.org/api/docs/
riskiq_api_username = '' riskiq_api_username = ''
+4 -4
View File
@@ -12,7 +12,7 @@ class GoogleAPI(Search):
self.addr = 'https://www.googleapis.com/customsearch/v1' self.addr = 'https://www.googleapis.com/customsearch/v1'
self.delay = 1 self.delay = 1
self.key = api.google_api_key self.key = api.google_api_key
self.cx = api.google_api_cx self.id = api.google_api_id
self.per_page_num = 10 # 每次只能请求10个结果 self.per_page_num = 10 # 每次只能请求10个结果
def search(self, domain, filtered_subdomain='', full_search=False): def search(self, domain, filtered_subdomain='', full_search=False):
@@ -29,7 +29,7 @@ class GoogleAPI(Search):
time.sleep(self.delay) time.sleep(self.delay)
self.header = self.get_header() self.header = self.get_header()
self.proxy = self.get_proxy(self.source) 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', 'q': word, 'fields': 'items/link',
'start': self.page_num, 'num': self.per_page_num} 'start': self.page_num, 'num': self.per_page_num}
resp = self.get(self.addr, params) 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 return
self.begin() self.begin()
self.search(self.domain, full_search=True) self.search(self.domain, full_search=True)
@@ -85,4 +85,4 @@ def do(domain): # 统一入口名字 方便多线程调用
if __name__ == '__main__': if __name__ == '__main__':
do('example.com') do('mi.com')