def main(): if (len(sys.argv) < 2): print "./fb_auto_commenter.py Brazil/English/French" return fb_auto_mail.write_file("---------------------------" + sys.argv[1] + "\n") try: display = Display(visible=0, size=(800, 600)) display.start() #打开区域权限 logging.info(">>>>>>>open limit") open_limit() #读取googledocs 群组信息 logging.info(">>>>>>>read from google docs") global french_groups_id french_groups_id = read_from_googledocs() #french_groups_id = ['309490585766406', '745769152175443', '1393190844256106', '1384933575085078', '1458512047714028', '1581747275377893', '778025652245798', '252563551503667', '1468450793419237'] logging.info(french_groups_id) #打开任务进程 logging.info(">>>>>>>start post task") start_task_process() #关闭权限 logging.info(">>>>>>>close limit") close_limit() logging.info(">>>>>>>send result mail") fb_auto_mail.send_mail() except Exception as e: logging.error(e) finally: logging.info("end") display.stop()
def add_task(user_info): try: global user_id global post_num global db post_num = 0 user_id = user_info[0] db = fb_sqlite_operate.fb_operate_db(user_id) logging.info("start new user:%s PID:%d", user_id, os.getpid()) web = fb_web.web_operate() web.do_login(user_info) #从网页获取群组ID和帖子ID,讲数据更新入sqlite3 if sys.argv[1] == credentials.FRENCH: googledocs_group(web) else: collect_group(web) #自动回帖操作 res = post_comments(web) if res == 0: content = "[%s]:%si\n" % (user_info[0], credentials.fb_locked_str) fb_auto_mail.write_file(content) except Exception as e: logging.error(e) finally: record_str = "[%s]:post comment number %d\n" % (user_id, post_num) logging.info("DOWN QUIT,%s", record_str) web.exit_browser() db.close_sqlite3() fb_auto_mail.write_file(record_str)
def main(): if (len(sys.argv) < 2): print "./fb_auto_commenter.py Brazil/English/French" return fb_auto_mail.write_file("---------------------------" + sys.argv[1] + "\n") try: display = Display(visible=0, size=(800,600)) display.start() #打开区域权限 logging.info(">>>>>>>open limit") open_limit() #读取googledocs 群组信息 logging.info(">>>>>>>read from google docs") global french_groups_id french_groups_id = read_from_googledocs() #french_groups_id = ['309490585766406', '745769152175443', '1393190844256106', '1384933575085078', '1458512047714028', '1581747275377893', '778025652245798', '252563551503667', '1468450793419237'] logging.info(french_groups_id) #打开任务进程 logging.info(">>>>>>>start post task") start_task_process() #关闭权限 logging.info(">>>>>>>close limit") close_limit() logging.info(">>>>>>>send result mail") fb_auto_mail.send_mail() except Exception as e: logging.error(e) finally: logging.info("end") display.stop()
def add_task(user_info): try: global user_id global post_num global db post_num = 0 user_id = user_info[0] db = fb_sqlite_operate.fb_operate_db(user_id) logging.info("start new user:%s PID:%d", user_id,os.getpid()) web = fb_web.web_operate() web.do_login(user_info) #从网页获取群组ID和帖子ID,讲数据更新入sqlite3 if sys.argv[1] == credentials.FRENCH: googledocs_group(web) else: collect_group(web) #自动回帖操作 res = post_comments(web) if res == 0: content = "[%s]:%si\n"%(user_info[0], credentials.fb_locked_str) fb_auto_mail.write_file(content) except Exception as e: logging.error(e) finally: record_str = "[%s]:post comment number %d\n"%(user_id, post_num) logging.info("DOWN QUIT,%s", record_str) web.exit_browser() db.close_sqlite3() fb_auto_mail.write_file(record_str)
def close_limit(): try: web = fb_web.web_operate() web.do_login(credentials.CONTROL_ACCOUNT) web.add_china_tag(credentials.COMMENT_LINK) logging.info("close limit successed") except Exception as e: fb_auto_mail.write_file("add china tag error--" + credentials.COMMENT_LINK + "\n") logging.error(e) finally: web.exit_browser()