def __init__(self): """存储器构造函数 我们通过MySQLdb连接到Mystatement数据库, 值得注意的是,这里使用unix套接字而非地址加端口号的形式连接到数据库 """ self.client = MySQLdb.connect(unix_socket=settings.UNIX_SOCKET, db=settings.MYSQL_DBMAS, user=settings.MYSQL_USER, passwd=settings.MYSQL_PASSWD, charset='utf8', use_unicode=True) self.cur = self.client.cursor() self.ema = emails.Email()
def __init__(self, start_url=None, increment=0, increment_max=0, *args, **kwargs): """ Args: start_url 起始地址 increment 起始条目 increment_max 终止条目 """ super(VH, self).__init__(*args, **kwargs) self.url = start_url self.ema = emails.Email() self.current = int(increment) # 当前条目 self.increment = int(increment) self.increment_max = int(increment_max)
def __init__(self, increment_low=0, increment_high=0, *args, **kwargs): """ Args: increment_low 起始条目 increment_high 终止条目 """ super(TP, self).__init__(*args, **kwargs) self.count = 0 # 每一轮已经完成的条目数 self.current_item = 0 self.increment_low = int(increment_low) self.increment_high = int(increment_high) self.all_items = self.increment_high - self.increment_low + 1 self.ema = emails.Email() # 无头浏览器配置 self.options = Options() self.options.add_argument('--headless') self.options.add_argument('--no-sandbox') self.options.add_argument('--disable-dev-shm-usage') self.options.add_argument('blink-settings=imagesEnabled=false') # 禁止下载图片,加快解析速度 self.driver = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=self.options)