1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
import json import requests import argparse
BDURL = "http://ce.baidu.com/index/getRelatedSites?site_address=" URLS = set({})
def baidu(url): res = requests.get(BDURL+url) a = json.loads(res.text) for i in a['data']: URLS.add(i['domain'])
if __name__ == '__main__': parser = argparse.ArgumentParser(description='Collect Subdomain.') parser.add_argument('--domain','-d',required=True,help='target domain') parser.add_argument('--file','-f',help='save file name.default is domain.txt') args = parser.parse_args()
baidu(args.domain)
print('[+]Collect Complete.') if args.file: with open(args.file,'w') as wf: wf.write('\n'.join(URLS)) print('[+]File Saved in',args.file) else: with open('domain.txt','w') as wf: wf.write('\n'.join(URLS)) print('[+]File Saved in domain.txt')
|