Example #1
0
def im_url(file_url,tables):
	if not os.path.exists(file_url):
		print '\033[1;31;1m   Sorry, the file does not exist.    \033[0m';
		exit();
	else:
		im_url_db = DB();
		sql = "select count(table_name) from information_schema.tables where table_name = '%s' and TABLE_SCHEMA = '%s'" % (tables,core.CORE.db)
  		if im_url_db.query(sql):
  			for url in open(file_url):
  				url = url.replace('http://','').replace('https://','').replace('\r','').replace('\n','');
  				im_resolver=dns.resolver.Resolver();
				im_resolver.nameservers=core.default_dns
				try:
					ip=im_resolver.query(url,'A')[0];
				except Exception,e:
					ip = False;
				if ip != False:
					sql = "select count(id) from %s where url = '%s' " % (tables,url);
					if not im_url_db.query(sql):
						sql = "insert into %s values (null,\"%s\",\"%s\",0,0,0,0)" % (tables,url,str(ip));
						im_url_db.increase(sql);
						print url,"===>OK",ip;
Example #2
0
File: hound.py Project: wsppt/hound
			function.a1();
		elif picture == 2:
			function.a2();
		elif picture == 3:
			function.a3();
		elif picture == 4:
			function.a4();
		lis = hound_db.query_all("select lis from lis"); #获取所有字典数据
		
		print "\033[1;35;1m  Dictionary--> %i Tools--> hound version--> 1.7 \033[0m  \n" % (len(lis));

		url = url.replace('http://','').replace('https://',''); #处理域名
		url_tables = url.replace('.','_').replace('-','_');
		sql = "select count(table_name) from information_schema.tables where table_name = '%s' and TABLE_SCHEMA = '%s'" % (url_tables,core.CORE.db)
				
		if not hound_db.query(sql): #判断表名存不存在 如果不存在就创建
			hound_db.increase(""" 
				create table %s(
				id int not null primary key auto_increment,
				url text not null comment 'url',
				ip varchar(40)	not null comment 'ip',
				recursion int not null comment 'digui',
				Crawler int not null comment 'pachong',
				cms text null comment 'shibiecms',
				dns int not null comment 'yuchuansong'
				)charset utf8 engine = innodb;
			""" % (url_tables) );
		try:
			u_resolver=dns.resolver.Resolver()
			ip = u_resolver.query(url,'A')
			if ip[0] :