# _______          ____ ________  ________  ________ 
# \   _  \ ___  __/_   /   __   \/   __   \/   __   \
# /  /_\  \\  \/  /|   \____    /\____    /\____    /
# \  \_/   \>    < |   |  /    /    /    /    /    / 
#  \_____  /__/\_ \|___| /____/    /____/    /____/  
#        \/      \/                                  
# Author	: 0x1999
# Date		: 8 February 2019
# Name 		: cubdomain.com domain extractor
# Usage 	: python cubdomain.py 2019-02-06
# Telegram  : @yxn1x

# Code request from my brother panataran

from sys import stdout
import requests,re,sys
date = sys.argv[1]
link = 'https://www.cubdomain.com/domains-registered-by-date/'+date+'/1'
r = requests.get(link)
totaldomain = re.search(r':</strong> (.*?)</li>', r.content.decode('utf-8')).group(1)
page=float(totaldomain)/5000
page=int(round(page))
weblist=re.findall('<a href="https://www.cubdomain.com/site/(.*?)">', r.content.decode('utf-8'))
print("# _______          ____ ________  ________  ________ \n# \   _  \ ___  __/_   /   __   \/   __   \/   __   \\\n# /  /_\  \\\\  \/  /|   \____    /\____    /\____    /\n# \  \_/   \>    < |   |  /    /    /    /    /    / \n#  \_____  /__/\_ \|___| /____/    /____/    /____/  \n#        \/      \/                                  \n# Author	: 0x1999\n# Date		: 8 February 2019\n# Name 		: cubdomain.com domain extractor\n# Usage 	: python cubdomain.py 2019-02-06\n# Telegram 	: @yxn1x")
link = 'https://www.cubdomain.com/domains-registered-by-date/'+date
for f in list(range(1,page+1)):
	try:
		f=str(f)
		url=link+'/'+f+'/'
		print("\n=====================[0x1999]=====================")
		print('Tanggal : '+date+' Page '+f+' Total Domain : '+totaldomain)
		r = requests.get(url)
		count = 0
		while (count < len(weblist)):
		   weblist=re.findall('<a href="https://www.cubdomain.com/site/(.*?)">', r.content.decode('utf-8'))
		   hasil='http://'+weblist[count]
		   file = open("cubdomain_"+date+".txt","a") 
		   file.write(hasil)
		   file.write("\n")
		   file.close()
		   count = count + 1
		   stdout.write("\rWriting : %d" % count)
		   stdout.flush()
		# print("\nSave into file cubdomain_"+date+".txt")
		stdout.flush()
	except:
        	pass
