def __init__(self, table_name='', webhook_url='', **kwargs): dispatcher.connect(self.spider_closed, signals.spider_closed) self.mydb = db.MydbOperator(table_name) print(webhook_url) self.webhook_service = webhook.WebHook(webhook_url) self.mydb.create_table() self.isInitialize = self.mydb.is_empty_table() print(self.isInitialize) self.page_limit = 5 super().__init__(**kwargs)
def __init__(self, table_name='', webhook_url='', site=[''], location='', **kwargs): dispatcher.connect(self.spider_closed, signals.spider_closed) self.start_urls = [ f'https://{site}.58.com/job/?key=%E5%A4%96%E8%B4%B8&classpolicy=main_null,job_A&final=1&jump=1' ] self.mydb = db.MydbOperator(table_name) print(webhook_url) self.webhook_service = webhook.WebHook(webhook_url) self.mydb.create_table() self.isInitialize = self.mydb.is_empty_table() print(self.isInitialize) self.location = location self.page_limit = 5 super().__init__(**kwargs)
def __init__(self, table_name='', webhook_url='', **kwargs): dispatcher.connect(self.spider_closed, signals.spider_closed) self.start_urls = [ f'https://fe-api.zhaopin.com/c/i/sou?pageSize=200&cityId=664&workExperience=-1&education=5&companyType=-1&employmentType=-1&jobWelfareTag=-1&kw=python&kt=3' ] # self.start_urls = url self.mydb = db.MydbOperator(table_name) option = ChromeOptions() tmp_path = './tem_path' prefs = { 'profile.default_content_settings.popups': 0, 'download.default_directory': tmp_path, "profile.default_content_setting_values.automatic_downloads": 1 } # 允许多个文件下载 option.add_experimental_option('prefs', prefs) option.add_experimental_option('excludeSwitches', ['enable-automation']) self.driver = webdriver.Chrome( options=option, executable_path="../bin/driver/chromedriver.exe") # self.driver = webdriver_chrome.gen_browser('../bin/driver/chromedriver.exe') self.webhook_service = webhook.WebHook(webhook_url) self.mydb.create_table() self.isInitialize = self.mydb.is_empty_table() self.page_limit = 5 # script = 'Object.defineProperty(navigator,"webdriver",{get:() => false,});' # # # 运行Javascript # # self.driver.execute_script(script) self.driver.execute_cdp_cmd( "Page.addScriptToEvaluateOnNewDocument", { "source": """ Object.defineProperty(navigator, 'webdriver', { get: () => undefined }) """ }) super().__init__(**kwargs)