def push_all(self): Log.info("<<POI push all>> start") if not IS_PUSH_TO_POI: return from models.merchant import MerchantModel merchants = MerchantModel.get_all(self.session) for merchant in merchants: try: self.push_by_merchant(merchant) except Exception as e: Log.debug(traceback.format_exc())
def see_url(browser: str, email: str, pw: str): log = Log(error_path='error.log', debug_path='normal.log', json_path='info.log') log.set_level(Log.stdout_level) # for test log.debug('test ' + browser + '_' + email) start = time.time() crawler = FacebookCrawler(user_name=email, password=pw, log=log, browser=browser) crawler.init() log.debug('init') crawler.login_facebook() log.debug('login') crawler.set_sleep(1) # info_dict = crawler.open_homepage_by_param(name='الزجوي عبدلاه', city='Cairo', country_code='EG') # print(info_dict) # info_dict = crawler.open_homepage_by_param(name='Angel Gunawan', city='Surabaya', country_code='ID') # print(info_dict) info_dict = crawler.open_homepage_by_param(name='Arman Ali', city='Gorakhpur', country_code='IN') print(info_dict) # info_dict = crawler.open_homepage_by_param(name='Jose Antonio Lara Gálvez', city='Jerez de la Frontera', # country_code='ES') # print(info_dict) # info_dict = crawler.open_homepage_by_param(name='Elena Iuliana', city='Bucharest', country_code='RO') # print(info_dict) end = time.time() log.debug('time cost:' + str(end - start) + ' s')
def browser_param(browser: str, email: str, pw: str): log = Log(error_path='error.log', debug_path='normal.log', json_path='info.log') log.set_level(Log.stdout_level) # for test log.debug('test ' + browser + '_' + email) start = time.time() crawler = FacebookCrawler(user_name=email, password=pw, log=log, browser=browser) crawler.init() crawler.login_facebook() # crawler.get_browser().save_screenshot('login.png') crawler.set_sleep(1) user_url = 'https://www.facebook.com/app_scoped_user_id/1758044224504993/' user_info = crawler.open_homepage_by_url(user_homepage=user_url) log.debug(user_info) end = time.time() log.debug('time cost:' + str(end - start) + ' s')
# encoding: utf-8 __author__ = 'zhanghe' from tools.log import Log # 实例化,修改日志文件名称,加载新配置 log_test = Log() log_test.log_filename = 'log_test.log' log_test.log_config() # 测试 log_test.debug('This is debug message') log_test.info('This is info message') log_test.warning('This is warning message') log_test.get_memory_usage() print log_test.memory_usage """ 测试结果: 内存使用4.14M 4.14M """