def break_out_players(driver): # try: if not driver.current_url.startswith( 'https://www.crime-club.nl/nav.php?p=prison'): Navigation.navigate_using_xpath_element(driver, Values.jail_x_path) WebSleep.wait_for_element_by_id(driver, 'ibox') print('navigating to prison') else: if Captcha.captcha_present(driver): Captcha.detect_and_solve_captcha(driver) driver.find_element_by_name('check').click() time.sleep(0.25) if ElementConditions.check_exists_by_class_name( driver, 'inhoud_c'): print('checking jail') for element in driver.find_elements_by_class_name('inhoud_c'): if 'Breek' in element.text: try: element.find_element_by_tag_name('input').click() # driver.find_element_by_xpath(Values.jail_all_x_path) time.sleep(0.15) except: break pass
def login(driver, user, passw): if driver.current_url == Values.login_page: if ElementConditions.check_exists_by_name(driver, 'username'): driver.find_element_by_name('username').send_keys(user) if ElementConditions.check_exists_by_name(driver, 'password'): driver.find_element_by_name('password').send_keys(passw) if ElementConditions.check_exists_by_name(driver, 'submit_login'): driver.find_element_by_name('submit_login').click() WebSleep.wait_for_element_by_x_path(driver, Values.timer_gym_x_path)
def main_thread(): # loading the driver print('loading client') try: driver = webdriver.Chrome('./driver/chromedriver.exe') driver.get('https://www.crime-club.nl/login.php') driver.maximize_window() WebSleep.wait_for_element_by_name(driver, 'submit_login') except Exception: print("error while loading driver") # the main loop while True: if (Values.running): try: if driver.current_url == Values.login_page: print('logging in') Login.login(driver, 'USERNAME', 'PASSWORD') elif driver.current_url == Values.index_page or driver.current_url == Values.base_page: print('navigatin to login page') Navigation.basic_navigation(driver, Values.login_page) # Gathering some data before starting to commit crimes # todo check if we got an crusher and the amount we can crush # todo check cars in garage # todo crush cars # todo check if we got an crusher and the amount we can crush else: if (ElementConditions.check_exists_by_xpath( driver, Values.rank_status_x_path)): Values.rank = driver.find_element_by_xpath( Values.rank_status_x_path).text if Values.jail_breakout_only == True: Navigation.navigate_using_xpath_element( driver, Values.jail_x_path) Jail.break_out_players(driver) else: if TimerStatus.timer_is_finished( driver, Values.timer_hookers_x_path ) and Rank.get_rank_id(Values.rank) > 2: Navigation.navigate_using_xpath_element( driver, Values.timer_hookers_x_path) BasicAction.commit_using_element_name( driver, Values.hookers_page, 'pimp') elif TimerStatus.timer_is_finished( driver, Values.timer_gym_x_path): Navigation.navigate_using_xpath_element( driver, Values.timer_gym_x_path) BasicAction.commit_using_element_name( driver, Values.gym_page, 'train') elif TimerStatus.timer_is_finished( driver, Values.timer_weapon_experience_x_path ) and Values.finished_weapon_training == False: Navigation.navigate_using_xpath_element( driver, Values.timer_weapon_experience_x_path) WeaponTraining.commit_and_update_weapon_training( driver) elif TimerStatus.timer_is_finished( driver, Values.timer_delivery_boy_x_path): Navigation.navigate_using_xpath_element( driver, Values.timer_delivery_boy_x_path) BasicAction.commit_using_element_name( driver, Values.delivery_boy_page, 'give_task') elif TimerStatus.timer_is_finished( driver, Values.timer_light_crime_x_path): Navigation.navigate_using_xpath_element( driver, Values.timer_light_crime_x_path) BasicAction.commit_using_element_name( driver, Values.crime_page, 'uitvoeren_licht') elif TimerStatus.timer_is_finished( driver, Values.timer_heavy_crime_x_path ) and Rank.get_rank_id(Values.rank) > 4: Navigation.navigate_using_xpath_element( driver, Values.timer_heavy_crime_x_path) BasicAction.commit_using_element_name( driver, Values.crime_page, 'uitvoeren_zwaar') elif TimerStatus.timer_is_finished( driver, Values.timer_light_carjack_x_path): Navigation.navigate_using_xpath_element( driver, Values.timer_light_carjack_x_path) BasicAction.commit_using_element_name( driver, Values.carjack_page, 'uitvoeren_licht') elif TimerStatus.timer_is_finished( driver, Values.timer_heavy_carjack_x_path ) and Rank.get_rank_id(Values.rank) > 4: Navigation.navigate_using_xpath_element( driver, Values.timer_heavy_carjack_x_path) BasicAction.commit_using_element_name( driver, Values.carjack_page, 'uitvoeren_zwaar') else: if Values.break_out_players_when_idle: Navigation.navigate_using_xpath_element( driver, Values.jail_x_path) Jail.break_out_players(driver) else: print('taking a rest') time.sleep(0.25) # time.sleep(0.25) except Exception: print('error in main loop')
import time import requests from selenium import webdriver from crime_club.actions.login import Login from crime_club.actions.navigation import Navigation from crime_club.conditions.element_conditions import ElementConditions from crime_club.conditions.web_sleep import WebSleep from crime_club.values import Values try: driver = webdriver.Chrome('./driver/chromedriver.exe') driver.get('https://www.crime-club.nl/login.php'); driver.maximize_window() WebSleep.wait_for_element_by_name(driver, 'submit_login') except Exception: print("error while loading driver") while True: if driver.current_url == Values.login_page: print('logging in') Login.login(driver, 'USERNAME', 'PASSWORD') elif driver.current_url == Values.index_page or driver.current_url == Values.base_page: print('navigatin to login page') Navigation.basic_navigation(driver, Values.login_page) else: if not driver.current_url.startswith('https://www.crime-club.nl/nav.php?p=wheeloffortune'):
from crime_club.conditions.web_sleep import WebSleep from crime_club.values import Values print('creating excel file') workbook = xlrd.open_workbook('data.xlsx') worksheet = workbook.sheet_by_name('1') wt_workbook = xlwt.Workbook('data.xlsx') wt_worksheet = wt_workbook.get_sheet('1') print('loading client') try: driver = webdriver.Chrome('./driver/chromedriver.exe') driver.get('https://www.crime-club.nl/login.php') driver.maximize_window() WebSleep.wait_for_element_by_name(driver, 'submit_login') except Exception: print("error while loading driver") while True: if driver.current_url == Values.login_page: print('logging in') Login.login(driver, 'USERNAME', 'PASSWORD') elif driver.current_url == Values.index_page or driver.current_url == Values.base_page: print('navigatin to login page') Navigation.basic_navigation(driver, Values.login_page) else: for x in range(1, 250):
def navigate_using_xpath_element(driver,element): if ElementConditions.check_exists_by_xpath(driver,element): driver.find_element_by_xpath(element).click() WebSleep.wait_for_element_by_x_path(driver,element)