generate_en_domain.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. '''
  4. @Contact : liuyuqi.gov@msn.cn
  5. @Time : 2023/03/08 20:18:13
  6. @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
  7. @Desc : 批量生成域名(双拼,双单词,双单词拼接)
  8. 参考项目: https://git.yoqi.me/lyq/SearchDomain
  9. '''
  10. import csv,os
  11. class GenerateEnDomain(object):
  12. def __init__(self, params: dict):
  13. '''初始化列表'''
  14. self.initList=[]
  15. self.params =params
  16. # self.keyword=["chat","ai"] # chat+xx
  17. self.keyword= self.params['keyword'].split(',')
  18. # self.yuming=["com","cn","me","net","co","run","wiki","tech","org","info","vip","cc","app","io","one","tk","xyz"]
  19. self.yuming=self.params["domain"].split(',')
  20. self.composeDomain=[]
  21. self.composePinYin=[]
  22. def run(self):
  23. with open(os.path.join(self.params["app_path"], r"data/b.csv"), "r", encoding="utf-8") as f:
  24. csv_data = f.readlines()
  25. for row in csv_data:
  26. self.initList.append(row.strip())
  27. for i in self.initList:
  28. for j in self.keyword:
  29. if self.params['position']=="prefix":
  30. self.composePinYin.append(i+j)
  31. else:
  32. self.composePinYin.append(j+i)
  33. for i in self.composePinYin:
  34. for j in self.yuming:
  35. self.composeDomain.append(i+"."+j)
  36. with open(os.path.join(self.params["app_path"], "domain.txt"),"w",encoding="utf-8") as file:
  37. for i in self.composeDomain:
  38. file.write(i+"\n")