Example #1
0
def load_max_lvl_dump(SOCIAL, SERVER, ID):
    '''open chrome'''
    driver = open_browser()
    '''go to admin panel'''
    driver.get(SOC_NET_LINKS['ADM'])
    '''login'''
    driver.find_element_by_id('YumUserLogin_username').send_keys(ADMIN_LOGIN)
    driver.find_element_by_id('YumUserLogin_password').send_keys(ADMIN_PASS)
    driver.find_element_by_name('yt0').click()
    '''select social network'''
    select = Select(driver.find_element_by_name('social'))
    select.select_by_value('DM')
    '''move mouse to dropdown menu'''
    dropdown = driver.find_element_by_id('yw1')
    first = dropdown.find_element_by_class_name('first')
    ActionChains(driver).move_to_element(first).perform()
    '''click to Дамп'''
    driver.find_element_by_link_text('Дамп').click()
    '''fill user field 1'''
    driver.find_element_by_class_name('inputtext').send_keys(SOCIAL + ID)
    '''select social network to get dump'''
    select = Select(driver.find_element_by_name('MDump[social]'))
    select.select_by_value(SERVER)
    '''click to button load list'''
    driver.find_element_by_link_text('load list').click()
    '''choose dump file'''
    select = Select(driver.find_element_by_id('s_dump'))
    '''find a max level dump'''
    max_level_dump = max(
        [int(re.findall(r'\d+', o.text[-5:])[0]) for o in select.options])
    '''choose max level dump'''
    select.select_by_visible_text('{}{}_{}_{}'.format(SOCIAL, ID,
                                                      str(max_level_dump),
                                                      SERVER))
    '''click to Target checkbox'''
    driver.find_element_by_name('MDump[t_accept]').click()
    '''fill user field 2'''
    driver.find_element_by_name('MDump[t_user]').send_keys(SOCIAL + ID)
    '''select social network to put dump'''
    select = Select(driver.find_element_by_name('MDump[t_social]'))
    select.select_by_value(SERVER)
    '''click to button Load dump'''
    driver.find_element_by_link_text('Load dump').click()
    '''accept loading'''
    alert = driver.switch_to_alert()
    alert.accept()

    time.sleep(3)
    driver.quit()
Example #2
0
 def setUp(self):
     ''''''
     '''ignore insides warnings'''
     warnings.simplefilter("ignore", ResourceWarning)
     warnings.simplefilter("ignore", DeprecationWarning)
     '''open chrome'''
     self.driver = browser.open_browser()
     '''go to social network'''
     browser.go_to_social_network(self.driver, SOC_NET_LINKS[SOCIAL])
     '''login'''
     browser.login(self.driver, SOC_AUTH_INFO[SOCIAL]['LOGIN'],
                   SOC_AUTH_INFO[SOCIAL]['PASS'])
     '''go to game page'''
     browser.go_to_social_network(self.driver,
                                  SOC_NET_LINKS['{}_game'.format(SOCIAL)])
Example #3
0
    def setUp(self):
        dump_loader.load_max_lvl_dump(SOCIAL, SERVER, SOC_AUTH_INFO[SOCIAL]['ID'])
        ''''''
        '''ignore insides warnings'''
        warnings.simplefilter("ignore", ResourceWarning)
        warnings.simplefilter("ignore", DeprecationWarning)

        '''open chrome'''
        self.driver = browser.open_browser()

        '''go to social network'''
        browser.go_to_social_network(self.driver, SOC_NET_LINKS[SOCIAL])

        '''login'''
        browser.login(self.driver, SOC_AUTH_INFO[SOCIAL]['LOGIN'], SOC_AUTH_INFO[SOCIAL]['PASS'])

        '''go to game page'''
        browser.go_to_social_network(self.driver, SOC_NET_LINKS['{}_game'.format(SOCIAL)])

        '''get screen resolution size'''
        self.width_screen, self.height_screen = pyautogui.size()

        '''find game's top menu'''
        self.left_coord_top_menu, self.top_coord_top_menu, self.width_top_menu, self.height_top_menu = \
            browser.monosearch_1000('top_menu.png', samples_dir)

        '''scroll down'''
        self.driver.execute_script('scroll({},{});'.format(self.left_coord_top_menu, self.top_coord_top_menu - 150))

        '''click to game area'''
        time.sleep(1)
        pyautogui.click(x=self.width_top_menu - self.left_coord_top_menu, y=self.top_coord_top_menu + self.height_screen / 2)

        '''accept flash running'''
        time.sleep(0.5)
        button_accept_flash_running = browser.monosearch_10('accept_flash_running.png', samples_dir)
        if button_accept_flash_running:
            button_accept_flash_running_x, button_accept_flash_running_y = pyautogui.center(button_accept_flash_running)
            pyautogui.click(x=button_accept_flash_running_x, y=button_accept_flash_running_y)
        self.REGIONS_ON_WINDOW, self.REGIONS_ON_FULL_SCREEN = regions.get_regions(self.left_coord_top_menu,
                                                                                  self.width_top_menu,
                                                                                  self.height_screen,
                                                                                  self.width_screen
                                                                                  )
        time.sleep(40)
Example #4
0
def wipe(SOCIAL, SERVER, ID):
    '''open chrome'''
    driver = open_browser()
    '''go to admin panel'''
    driver.get(SOC_NET_LINKS['ADM'])
    '''login'''
    driver.find_element_by_id('YumUserLogin_username').send_keys(ADMIN_LOGIN)
    driver.find_element_by_id('YumUserLogin_password').send_keys(ADMIN_PASS)
    driver.find_element_by_name('yt0').click()
    '''select social network'''
    select = Select(driver.find_element_by_name('social'))
    select.select_by_value(SERVER)
    '''click to Пользователи'''
    driver.find_element_by_link_text('Пользователи').click()
    '''find user'''
    driver.find_element_by_id('Filter__id.match').send_keys(SOCIAL + ID)
    driver.find_element_by_id('Filter_aka.match').click()
    '''click to user ID'''
    try:
        full_ID = WebDriverWait(driver, 10).until(
            expected_conditions.visibility_of_element_located(
                (By.LINK_TEXT, SOCIAL + ID)))
        full_ID.click()
        '''click to button К списку'''
        tabs = driver.find_element_by_class_name('tabs')
        tabs.find_element_by_class_name('button').click()
        '''click to button Удалить'''
        driver.find_element_by_class_name('remove').click()
        '''accept deleting'''
        time.sleep(2)
        alert = driver.switch_to_alert()
        alert.accept()

        time.sleep(3)
        driver.quit()
    except Exception:
        driver.quit()
Example #5
0
def extract_naver_map():
    TITLE = []
    ADDRESS = []
    PHONE = []
    URL = []
    query = loc.get()+" "+keyword.get()
    browser = open_browser(query)
    wait = WebDriverWait(browser, 30)
    by_xpath = By.XPATH, "//object[@id='searchIframe']"
    wait.until(EC.presence_of_element_located(by_xpath))
    time.sleep(3)
    search_frame = browser.find_element_by_xpath("//object[@id='searchIframe']")
    browser.switch_to.frame(search_frame)
    last_page = int(get_pages(browser))
    get_browser(browser, query)
    wait.until(EC.presence_of_element_located(by_xpath))
    search_frame = browser.find_element_by_xpath("//object[@id='searchIframe']")
    browser.switch_to.frame(search_frame)
    for p in range(last_page):
        print(f"----------------------------------------------------\n\nextracting page{p+1}/{last_page}\n\n----------------------------------------------------\n\n")
        time.sleep(1)
        while True:
            atags_1 = browser.find_elements_by_class_name('_2aE-_')
            if len(atags_1) == 0:
                atags_1 = browser.find_elements_by_class_name('Tx7az') 
            browser.execute_script("document.querySelector('._1Az1K').scrollTo(document.querySelector('._1Az1K').scrollTop, document.querySelector('._1Az1K').scrollHeight);")
            atags = browser.find_elements_by_class_name('_2aE-_')
            if len(atags) == 0:
                atags = browser.find_elements_by_class_name('Tx7az')
            if len(atags_1) == len(atags):
                break
        print(f"현 페이지 총 아이템 수: {len(atags)}\n\n")
        #extract
        by_xpath = By.XPATH, '//object[@id="entryIframe"]'
        for a in atags:
            a.click()
            time.sleep(1)
            browser.switch_to_default_content()
            wait.until(EC.presence_of_element_located(by_xpath))
            url = browser.find_elements_by_tag_name('object')[1].get_attribute('data')
            browser.execute_script("window.open('');")
            browser.switch_to_window(browser.window_handles[-1])
            browser.get(url)
            try:
                html = browser.execute_script('return document.body.outerHTML')
                soup = BeautifulSoup(html,'html.parser')
            except WebDriverException:
                browser.close()
                browser.switch_to_window(browser.window_handles[0])
                entry_frame = browser.find_element_by_xpath('//object[@id="entryIframe"]')
                browser.switch_to_frame(entry_frame)
                html = browser.execute_script('return document.body.outerHTML')
                soup = BeautifulSoup(html,'html.parser')
                browser.switch_to_default_content()
            title = soup.find('span', {'class': '_3XamX'}).text
            address = soup.find('span',{'class': '_2yqUQ'}).text
            phone = soup.find('li', {'class': '_3xPmJ'})
            if phone:
                phone = phone.text.split('안내')[0]
            else:
                phone = None
            if len(browser.window_handles) >1 :
                browser.close()
                browser.switch_to_window(browser.window_handles[0])
            else:
                pass
            browser.switch_to.frame(search_frame)
            TITLE.append(title)
            ADDRESS.append(address)
            PHONE.append(phone)
            URL.append(url)
            df = pd.DataFrame({'상호명': TITLE, '주소': ADDRESS, '전화번호': PHONE, '링크': URL})
            df.to_csv(f'{query}.csv', encoding='utf-8')
        #click next page
        next_btn = browser.find_elements_by_class_name('_3pA6R')[1]
        next_btn.click()
    print('finished!')
    clean_data(query)
    messagebox.showinfo('info', '완료')
Example #6
0
    from authentication_info import ADMIN_LOGIN, ADMIN_PASS, SOC_AUTH_INFO, SOC_NET_LINKS

    SOCIAL = 'FB'  # 'VK', 'FB'
    SERVER = 'FB'  # 'DM', 'FB'
    ID = SOC_AUTH_INFO[SOCIAL]['ID']


    n = 1
    times = []
    while True:
        start_time = datetime.datetime.now()
        logging.info('\n\n\n         tutor test, launch {}'.format(n))
        logging.info('start')

        wipe_user_progress.wipe(SOCIAL, SERVER, ID)
        driver = browser.open_browser()
        browser.go_to_social_network(driver, SOC_NET_LINKS[SOCIAL])
        browser.login(driver, SOC_AUTH_INFO[SOCIAL]['LOGIN'], SOC_AUTH_INFO[SOCIAL]['PASS'])
        browser.go_to_social_network(driver, SOC_NET_LINKS['{}_game'.format(SOCIAL)])
        width_screen, height_screen = browser.get_screen_resolution_size()
        left_coord_top_menu, top_coord_top_menu, width_top_menu, height_top_menu = browser.monosearch_1000('top_menu.png', samples_dir)
        REGIONS_ON_WINDOW, REGIONS_ON_FULL_SCREEN = regions.get_regions(left_coord_top_menu,
                                                                        width_top_menu,
                                                                        height_screen,
                                                                        width_screen)
        browser.scroll_down(driver, left_coord_top_menu, top_coord_top_menu)
        browser.click_to_game_area(width_top_menu, left_coord_top_menu, top_coord_top_menu, height_screen)
        browser.accept_flash_running(REGIONS_ON_FULL_SCREEN['left_up'], samples_dir)


        # time.sleep(40)
Example #7
0
# -*- coding: utf-8 -*-
# @Author: caspar
# @Date:   2018-08-11 11:44:18
# @Last Modified by:   Pandarison
# @Last Modified time: 2018-08-26 11:45:50

from autolol import app
from browser import open_browser

import sys

if len(sys.argv) < 2:
    app()
else:
    if sys.argv[1] == 'browser':
        open_browser(sys.argv[2])