def spider_opened(self, spider):
self.conn = MySQLdb.connect(host=settings.MYSQL_HOST, db=settings.MYSQL_DB, user=settings.MYSQL_USER, passwd=settings.MYSQL_PASSWORD, charset='utf8', use_unicode=True)
cursor = spider.conn.cursor()
sql_str = "SELECT pattern from whitelist"
cursor.execute(sql_str)
self.custom_whitelist = cursor.fetchall()
try:
alexa_whitelist_file = pkgutil.get_data("malspider", "resources/alexa-1k-whitelist.csv").decode('ascii')
self.alexa_whitelist = alexa_whitelist_file.splitlines()
except:
log.msg("Error loading alexa whitelist...", level=log.ERROR)
评论列表
文章目录