def check_captcha(browser, task_id, task_type, owner_id, email, password): cur = get_cursor() lastrun_date = datetime.datetime.now() completed_date = lastrun_date update_status = bottask_status.CAPTCHA_SOLVING done = False while done == False: try: selector = browser.find_element_by_css_selector("#noCaptchaIframe") # when this is ready on ui, use this # cur.execute(bottask_update_query, (update_status, lastrun_date, # completed_date, task_id, task_type, owner_id)) send_email(email, password, get_ip()) time.sleep(IDLE_INTERVAL_IN_SECONDS) except Exception as err: print('noCaptchaIframe:', err) done = True return True
def test_handle_message(): cur = get_cursor() cur.execute("SELECT * FROM app_bottask where status ='%s' or status='%s' order by id desc limit 1" % (bottask_status.QUEUED, bottask_status.PIN_CHECKING)) row = cur.fetchone() print('row:', row) if row is not None and row[1] == bottask_type.POSTMESSAGE: handle_checkmessage(cur, row)
def check_and_add_ip(cur=None): if cur is None: cur = get_cursor() ip = get_ip() row = check_bot_ip(cur, ip) if row is None: print('{0} ip is not in app_freebotip table'.format(ip)) add_to_db2(cur, insert_query, ip)
def test_insert(): sql = """INSERT INTO messenger_inbox (`company`, `industry`, `location`, `title`, `linkedin_id`, `name`, `latest_activity`,`status`, `is_connected`, `connected_date`, `owner_id`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')""" v = ('MTI TECHNOLOGY Co., Ltd', '', 'Vietnam', 'Vice General Director', 'yuji-tsuchiya-055b5828', 'Yuji Tsuchiya', '2018-05-10 12:42:36.857662', 22, 1, '2018-05-10 12:42:36.857662', 35) # sql = sql % v print("sql:", sql) cur = get_cursor() cur.execute(sql, v)
def read_mysql(): cur = botdb.get_cursor() while True: print("checking....") row = get_task_row(cur) if row is None: time.sleep(IDLE_INTERVAL_IN_SECONDS * 3) continue rows_count = 1 task_type = "" owner_id = "" print(row) task_id = row[0] task_type = row[1] owner_id = row[6] if rows_count > 0: # cur.execute("SELECT * FROM app_bottask WHERE id=%s" % rows_count) ##rows = cur.fetchall() print('task_type:', task_type) # LOGIN if task_type == tasktype.LOGIN: handle_login(cur, owner_id, task_id, task_type) # CONTACT elif task_type == tasktype.CONTACT: handle_contact(cur, owner_id, task_id, task_type) # GET MESSAGES elif task_type == tasktype.MESSAGING: handle_message(cur, owner_id, task_id, task_type) # SEARCH elif task_type == tasktype.SEARCH: handle_search(cur, owner_id, task_id, task_type, row) # PIN VERIFY elif task_type == tasktype.PINVERIFY: # get pin handle_pinverify(cur, owner_id, task_id, task_type, row) time.sleep(IDLE_INTERVAL_IN_SECONDS)
def test_search(): #driver = login_linkedin_withwebdriver(user_email, user_pw) #driver = botdriver.marionette_driver(headless=False) cur = botdb.get_cursor() return search( user_email, user_pw, 'b2b', cur, 1, 1, )
def read_mysql(): cur = botdb.get_cursor() while True: print("checking....") cur.execute( "SELECT * FROM app_bottask where status ='%s' or status='%s' order by id desc limit 1" % (botstatus.QUEUED, botstatus.PIN_CHECKING)) row = cur.fetchone() if row is None: time.sleep(IDLE_INTERVAL_IN_SECONDS) continue rows_count = 1 task_type = "" owner_id = "" print(row) task_id = row[0] task_type = row[1] owner_id = row[6] if rows_count > 0: # cur.execute("SELECT * FROM app_bottask WHERE id=%s" % rows_count) # rows = cur.fetchall() print('task_type:', task_type) # LOGIN if task_type == tasktype.LOGIN: email, password = get_user_email_pw(cur, owner_id) start_status = "RUNNING" cur.execute(running_update_query, (start_status, task_id, task_type, owner_id)) cur.execute("SELECT * FROM app_bottask") check_td = cur.fetchall() print(check_td) bot_result = login_linkedin(email, password) status = bot_result[0] lastrun_date = bot_result[1] completed_date = bot_result[2] cur.execute(bottask_update_query, (status, lastrun_date, completed_date, task_id, task_type, owner_id)) # CONTACT elif task_type == tasktype.CONTACT: handle_contact(cur, owner_id, task_id, task_type) # GET MESSAGES elif task_type == tasktype.MESSAGING: handle_message(cur, owner_id, task_id, task_type) # SEARCH elif task_type == tasktype.SEARCH: handle_search(cur, owner_id, task_id, task_type, row) # PIN VERIFY elif task_type == tasktype.PINVERIFY: # get pin handle_pinverify(cur, owner_id, task_id, task_type, row) # Connect elif task_type == tasktype.POSTCONNECT: handle_connect(cur, owner_id, task_id, task_type, row) time.sleep(IDLE_INTERVAL_IN_SECONDS)
def test_message(): get_messages(user_email, user_pw, bot_db.get_cursor(), 59)
def test_message(): driver = login_linkedin_withwebdriver(user_email, user_pw) #time.sleep(10) get_fastmessage(user_email, user_pw, get_cursor(), 77, driver)
# name and id_ tag_a = member.find('a', class_='name-link') print( member) # info """ driver.close() user_email = os.environ.get('email', None) user_pw = os.environ.get('pw', None) if __name__ == '__main__': cur = get_cursor() """" values = ('Fabindia Overseas Pvt Ltd', '', 'Gurgaon, India', "HeadOfDigital@Fabindia/ IMPACT 50MostInfluntialW'men", '3377770,3-D0', 'Gauri Awasthi', 111, 50, 5) add_to_db2(cur, search_query, *values) """ email = user_email password = user_pw search_data = "https://www.linkedin.com/sales/search?keywords=do%20less%20earn%20more&updateHistory=true&EL=auto&trk=d_sales2_nav_advancedsearch&trackingInfoJson.contextId=1496A604534F3715802CA711E62A0000" # cur = None search_id = 51 owner_id = 111 search_mode = 2 limit = 1000
def test_contact(url): #driver = login_linkedin_withwebdriver(user_email, user_pw) cur = botdb.get_cursor() get_contacts(user_email, user_pw, cur, 1)