From 953b7a4e9ba1f1d76897c7901bdb6e1f4e41de1f Mon Sep 17 00:00:00 2001 From: shmilylty Date: Fri, 18 Oct 2019 00:33:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=99=BE=E5=BA=A6=E4=BA=91?= =?UTF-8?q?=E8=A7=82=E6=B5=8B=E6=8E=A5=E5=8F=A3=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oneforall/modules/datasets/cebaidu.py | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 oneforall/modules/datasets/cebaidu.py diff --git a/oneforall/modules/datasets/cebaidu.py b/oneforall/modules/datasets/cebaidu.py new file mode 100644 index 0000000..c19e7c1 --- /dev/null +++ b/oneforall/modules/datasets/cebaidu.py @@ -0,0 +1,52 @@ +import time +from common.query import Query + + +class CeBaidu(Query): + def __init__(self, domain): + Query.__init__(self) + self.domain = self.register(domain) + self.module = 'Dataset' + self.source = 'CeBaiduQuery' + self.addr = 'http://ce.baidu.com/index/getRelatedSites' + + def query(self): + """ + 向接口查询子域并做子域匹配 + """ + time.sleep(self.delay) + self.header = self.get_header() + self.proxy = self.get_proxy(self.source) + params = {'site_address': self.domain} + resp = self.get(self.addr, params) + if not resp: + return + subdomains = self.match(self.domain, str(resp.json())) + # 合并搜索子域名搜索结果 + self.subdomains = self.subdomains.union(subdomains) + print(self.subdomains) + + def run(self): + """ + 类执行入口 + """ + self.begin() + self.query() + self.finish() + self.save_json() + self.gen_result() + self.save_db() + + +def do(domain): # 统一入口名字 方便多线程调用 + """ + 类统一调用入口 + + :param str domain: 域名 + """ + query = CeBaidu(domain) + query.run() + + +if __name__ == '__main__': + do('example.com')