[์นด์นด์˜ค๋ทฐ ์ž๋™ํ™”] ์นด์นด์˜คํ†ก ์ž๋™ ์‹คํ–‰ ํ›„ ์ฑ„๋„ ์ ‘์†ํ•˜์—ฌ ์‹ ๊ทœ ๋ณด๋“œ ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ 2๋‹จ๊ณ„
๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋””์ง€ํ„ธ ๊ฟ€ํŒ

[์นด์นด์˜ค๋ทฐ ์ž๋™ํ™”] ์นด์นด์˜คํ†ก ์ž๋™ ์‹คํ–‰ ํ›„ ์ฑ„๋„ ์ ‘์†ํ•˜์—ฌ ์‹ ๊ทœ ๋ณด๋“œ ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ 2๋‹จ๊ณ„

by ์ผ์ƒ์„ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค 2022. 9. 16.

๊ฒฐ๊ตญ์—” ๋ชจ๋ฐ”์ผ์—์„œ python ๋Œ๋ฆฌ๋Š” ๊ฒƒ์ด๋ผ๋Š” ๊ฑธ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ต๋‹ˆ๋‹ค. ๋‹ค๋งŒ ์Šคํฌ๋กค์ด๋‚˜ ์ด๋Ÿฐ ๋ถ€๋ถ„์ด ์›น์ด๋ž‘ ๋‹ฌ๋ผ์„œ ๋ชจ๋ฐ”์ผ ๊ธฐ๋Šฅ๋งŒ ์ตํžˆ๊ณ  ์žˆ๋‹ค๋ฉด ๊ธˆ๋ฐฉ ๊ตฌํ˜„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

[์นด์นด์˜ค๋ทฐ ์ž๋™ํ™”] ์นด๋ทฐ ๊ด€๋ฆฌ ์ž๋™ํ™”๋ฅผ ์œ„ํ•œ appium ์‚ฌ์šฉ ๋ง›๋ณด๊ธฐ 1๋‹จ๊ณ„

์˜ˆ๋ž‘์ด๊ฐ€ ์ด๋Ÿฐ ํ…Œ์ŠคํŠธ ์ž๋™ํ™” ํ”„๋กœ๊ทธ๋žจ์ด ์žˆ๋‹ค๋Š” ๊ฑธ ์•Œ๋ ค์ค˜์„œ ์ ‘ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒ˜์Œ ํ•ด๋ณด๋Š” ๊ฒƒ์ด๋ผ์„œ ๋‚ฏ์„ค์—ˆ์ง€๋งŒ, ๋‹ค๋ฅธ ์–ธ์–ด๋“ค์ฒ˜๋Ÿผ ์ฒซ ์…‹ํŒ…๋งŒ ์ž˜ํ•ด๋ณด๋ฉด ๋‹ค ๋น„์Šทํ•˜๊ณ  ๊ฒฐ๊ตญ์—” python์œผ๋กœ ์ฝ”๋”ฉ

odaily.tistory.com

 

 

์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” ์นด๋ทฐ๋ฅผ ๋ชจ๋ฐ”์ผ์—์„œ ์ž๋™์œผ๋กœ ์‹คํ–‰ํ•˜์—ฌ ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ์„ ํ†ตํ•ด ์ฑ„๋„ ์ ‘์† ํ›„ ๋ณด๋“œ ์ •๋ณด ๊ฐ€์ ธ์˜ค๋Š” ๋ฐฉ๋ฒ• ์ž…๋‹ˆ๋‹ค. ํ•œ ์ฑ„๋„์˜ 1 ๋ณด๋“œ๋ฅผ ์˜ˆ์‹œ๋กœ ์ž‘์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค. ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ ๋ฒˆ์— ๋‹ค๋ฃจ๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. 

ํ•„์š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ฐ ๋ณ€์ˆ˜ ์„ ์–ธ 

from selenium.webdriver.common.by import By
from appium import webdriver
from time import sleep
import gspread
import emoji
import re
import json
 
ํŒŒ์ด์ฌ์˜ ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค.   ๋ณ€์ˆ˜ ์„ ์–ธ ๋ฐ ์ฑ„๋„ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋„๋ก ๊ตฌ๊ธ€ ์Šคํ”„๋ ˆ๋“œ ์‹œํŠธ๋ฅผ ์ด์šฉํ•ฉ๋‹ˆ๋‹ค.
#๊ณต์œ  ์ฑ„๋„ ์ •๋ณด ๊ฐ€์ง€๊ณ ์˜ค๊ธฐ
channel_list = []

#์ฑ„๋„๋ณ„ ๋ณด๋“œ ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ (์ œ๋ชฉ, ๋ณด๋“œ ๋งํฌ)
board_title_list = []
board_url_list = []

PAUSE_TIME = 0.1
LOADING_WAIT_TIME = 2


#๊ตฌ๊ธ€ ๋ฌธ์„œ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ INFO ํŒŒ์ผ
with open('/Users/program/info_mobile.json') as json_file:
    info = json.load(json_file)

APPIUM ๊ธฐ๋ณธ ์„ค์ •

caps = {}
caps["platformName"] = "Android"
caps["appium:platformVersion"] = "์†Œํ”„ํŠธ์›จ์–ด ๋ฒ„์ „"
caps["appium:deviceName"] = "ํœด๋Œ€ํฐ์— ์„ค์ •๋œ ์ด๋ฆ„"
caps["appium:app"] = "APK ํŒŒ์ผ ๊ฒฝ๋กœ"
caps["appium:automationName"] = "Appium"
caps["appium:newCommandTImeout"] = 300
caps["appium:appPackage"] = "์นด์นด์˜คํ†ก ํŒจํ‚ค์ง€ ๋ช…"
caps["appium:appActivity"] = "์นด์นด์˜คํ†ก ๋ฉ”์ธ Activity"
caps["appium:udid"] = "adb๋กœ ๊ฐ€์ ธ์˜จ ํœด๋Œ€ํฐ udid ๊ฐ’"
caps["appium:noReset"] = "true" #ํ•œ ๋ฒˆ ์‹คํ–‰ํ•˜์—ฌ ์ธ์ฆ ๋ฐ›์œผ๋ฉด ํ•ด๋‹น ์ •๋ณด๋ฅผ ์œ ์ง€
caps["appium:fullReset"] = "false" #์ดˆ๊ธฐํ™” ์„ค์ • 
caps["appium:ensureWebviewsHavePages"] = True 
caps["appium:nativeWebScreenshot"] = True 
caps["appium:newCommandTimeout"] = 3600 
caps["appium:connectHardwareKeyboard"] = True

driver = webdriver.Remote("http://0.0.0.0:4723/wd/hub", caps)

1. ์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ ์นด์นด์˜คํ†ก์„ ์‹คํ–‰์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.  ์ž์„ธํ•œ ๊ฐ€์ด๋“œ ๋งํฌ : https://appium.io/docs/en/writing-running-appium/caps/

2. ๋””๋ฐ”์ด์Šค udid ๊ฐ’ ํ™•์ธ ๋ฐฉ๋ฒ•

 

[android]๋กœ๊ทธ ์ˆ˜์ง‘ ํ•˜๋Š” ๋ฐฉ๋ฒ•

Android ๋ฒ„์ „์ด ์—…๋ฐ์ดํŠธ ๋˜๋ฉด์„œ ๊ธฐ๊ธฐ์—์„œ ๋ฐ”๋กœ ๋กœ๊ทธ ์ถ”์ถœ์ด ๋ถˆ๊ฐ€ํ•ด์กŒ๋‹ค. ์•Œ์•„๋‘๋ฉด ์ข‹์€ ๋กœ๊ทธ ์ˆ˜์ง‘ํ•˜๋Š” ๋ฐฉ๋ฒ•(adb tool ์‚ฌ์šฉ๋ฐฉ๋ฒ•)์„ ๊ธฐ๋กํ•ด๋ณธ๋‹ค. ์œˆ๋„์šฐ์—์„œ ์•ˆ๋“œ๋กœ์ด๋“œ ๋กœ๊ทธ ์ˆ˜์ง‘ ๋งค๋‰ด์–ผ [์‚ฌ์ „์ค€๋น„]

odaily.tistory.com

 

 

๋ณด๋“œ ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ

์ฑ„๋„์— ๋“ค์–ด๊ฐ€์„œ ๋ณด๋“œ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐฉ๋ฒ•์„ ๊ธฐ์žฌํ•˜์˜€์Šต๋‹ˆ๋‹ค. 

def newBoard(channelName):
    #๊ธˆ์ผ ์ƒˆ๋กœ์šด ๋ณด๋“œ 00 ~ 23 (h ๊ธฐ์ค€)	
    #๋ณด๋“œ ์ œ๋ชฉ, url, ๊ฐฏ์ˆ˜ 
    title = ""
    board_url =""
    count = 0
    
    #์ฐพ์„ ์ฑ„๋„๋ช…
    print("\์ฑ„๋„๋ช… :", channelName)
    
    #์นด์นด์˜ค๋ทฐ ๊ฒ€์ƒ‰ ๋ฒ„ํŠผ ํด๋ฆญ
    ele = driver.find_element(By.XPATH, value='//android.widget.TextView[@content-desc="๊ฒ€์ƒ‰ ๋ฒ„ํŠผ"]')
    ele.click()
    sleep(LOADING_WAIT_TIME)
    
    #์ฑ„๋„๋ช… ๊ฒ€์ƒ‰์— ์ž…๋ ฅ
    ele = driver.find_element(By.XPATH, value='/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.EditText')
    ele.send_keys(channelName)    
    sleep(LOADING_WAIT_TIME)
    
    #๊ฒ€์ƒ‰๋œ ๊ฒฐ๊ณผ์—์„œ ์ฑ„๋„ ํด๋ฆญํ•˜์—ฌ ์นด์นด์˜ค๋ทฐ ์ฑ„๋„๋กœ ๋“ค์–ด๊ฐ€๊ธฐ
    ele = driver.find_element(By.XPATH, value='//android.view.View[@content-desc="ํ”„๋กœํ•„ ์‚ฌ์ง„"][1]')
    ele.click()
    sleep(LOADING_WAIT_TIME)
    sleep(LOADING_WAIT_TIME)
    
    #์ฑ„๋„์—์„œ ๋ณด๋“œ ํƒญ ํด๋ฆญ
    ele = driver.find_element(By.XPATH, value='//android.widget.LinearLayout[@content-desc="๋ณด๋“œ"]/android.widget.LinearLayout/android.widget.TextView')
    ele.click()
    sleep(LOADING_WAIT_TIME)
    
    #์‹ ๊ทœ ๋ณด๋“œ ์—ฌ๋ถ€ flag
    bValue = True 
    count = 0

    while bValue :
    	#๋ณด๋“œ์— ๋ช‡์‹œ๊ฐ„ ์ „ ํ•„๋“œ ๊ฐ€์ ธ์˜ค๊ธฐ
        ele = driver.find_element(By.XPATH, value='//android.widget.LinearLayout[@content-desc="' + channelName + ', ์ฑ„๋„"]/android.widget.LinearLayout[2]/android.widget.TextView')
        sleep(LOADING_WAIT_TIME)
        time = ele.get_attribute("text")
        
        #23์‹œ๊ฐ„์ „ ์ˆซ์ž ๊ตฌ๋ถ„ํ•˜๊ธฐ (1์ผ ์ „)
        replaceTime(text)
        
        print("์ž‘์„ฑ ์‹œ๊ฐ„ : " , time)
        sleep(LOADING_WAIT_TIME)
    
    	#๊ฐ€์ ธ์˜จ ์‹œ๊ฐ„์ด 1์ผ ์ „์ด ์•„๋‹ ๊ฒฝ์šฐ ๋ณด๋“œ ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ
        #์‹ ๊ทœ ๋ณด๋“œ ํŒŒ์•…์„ ์œ„ํ•œ ์กฐ๊ฑด๋ฌธ
       	if hour.isnumeric():
            ele_arry = driver.find_elements(By.ID, value='com.kakao.talk:id/title')
            sleep(LOADING_WAIT_TIME)        
            
            if len(ele_arry) == 4 :
                title = deEmojify(ele_arry[3].text)
            elif len(ele_arry) == 3 :
                title = deEmojify(ele_arry[2].text)
            else :               
                title = deEmojify(ele_arry[4].text)

            sleep(LOADING_WAIT_TIME)    
                
            xword = '//android.widget.FrameLayout[@content-desc="๋”๋ณด๊ธฐ, ๋ฒ„ํŠผ, ' + channelName + '"]/android.widget.ImageView'

            ele_link_arry = driver.find_elements(By.XPATH, value=xword)
            sleep(LOADING_WAIT_TIME)
            
            if len(ele_link_arry) == 2 :
                ele_link_arry[1].click()
            else :
                ele_link_arry[0].click()
            sleep(LOADING_WAIT_TIME)
            
            #๋ณต์‚ฌํ•œ ๋ณด๋“œ ๋งํฌ๊ฐ’ ๊ฐ€์ ธ์˜ค๊ธฐ
            board_url = driver.get_clipboard_text()
            sleep(LOADING_WAIT_TIME)          
            sleep(LOADING_WAIT_TIME)
            
            #์ตœ์ข… ์‹ ๊ทœ ๋ณด๋“œ ์ˆ˜๋ฅผ ํŒŒ์•…ํ•˜๊ธฐ ์œ„ํ•œ ๋ฐฐ์—ด์— ๋ฐ์ดํ„ฐ ๋„ฃ๊ธฐ
            board_title_list.append (title)
            board_url_list.append(board_url)
            
            #๋ณด๋“œ ์ˆ˜ ์นด์šดํŠธํ•˜๊ธฐ
            count = count + 1
            
            #์ฝ˜์†”์— ๋กœ๊ทธ ์ถœ๋ ฅ
            print(count , ".", channelName , "/ ์ œ๋ชฉ : " , title , " / ๋ณด๋“œ๋งํฌ : " + board_url) 
            
            title = ""
            board_url= ""
            
            # ์ฑ„๋„์—์„œ ์•„๋ž˜ ๋ณด๋“œ๋กœ ๊ฐ€๊ธฐ ์ถ”ํ›„ ๊ณ„์‚ฐ์‹์œผ๋กœ ๋ณ€๊ฒฝ ์˜ˆ์ •
            driver.swipe(start_x=650,start_y=2000,end_x=650,end_y=520)
            
            # ๊ณ„์‚ฐ์‹ - ์•„๋ž˜ ์ •์˜
            # board_swipe()
            sleep(LOADING_SCROLL_WAIT_TIME)
            sleep(LOADING_SCROLL_WAIT_TIME)

        else :
        	#time์ด 1์ผ ์ „์ผ ๊ฒฝ์šฐ ํ•ด๋‹น ์ฑ„๋„ ๋ณด๋“œ ํƒ์ƒ‰ ์ข…๋ฃŒ
            bValue = False
            
            #ํ˜„์žฌ๊นŒ์ง€ ํ•ด๋‹น ์ฑ„๋„์—์„œ countํ•œ ๋ณด๋“œ ์ˆ˜ ์ถœ๋ ฅ 
            print("\n ์ฑ„๋„๋ช… ", channelName,  ", ์‹ ๊ทœ ๋ณด๋“œ ์ˆ˜ :", count, " Update ์™„๋ฃŒ")

*title ๊ฐ€์ ธ์˜ค๋Š” ๋ถ€๋ถ„์—  ์˜ค๋ฅ˜๊ฐ€ ์žˆ์–ด ์ถ”ํ›„ ์ˆ˜์ • ์˜ˆ์ •์ž…๋‹ˆ๋‹ค. ๋™์ž‘์˜ ์˜ˆ์‹œ๋ฅผ ์œ„ํ•œ ์ƒ˜ํ”Œ ์ฝ”๋“œ๋ผ๊ณ  ์ƒ๊ฐ ๋ถ€ํƒ๋“œ๋ ค์š”. Appium Inspector๋กœ ํ™•์ธํ•ด๋ณด๋‹ˆ Title element์— ์•„๋ž˜๊ฐ™์€ ์„ค๋ช…์ด ์žˆ์—ˆ๋‹ค. XPATH๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ๋ง๋ผ๊ณ  ๊ฒฝ๊ณ  ๋ฌธ๊ตฌ๊ฐ€ ์žˆ์–ด ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์œผ๋กœ ๋ณด๋“œ ์ œ๋ชฉ์„ ๊ฐ€์ ธ์™€๋ณผ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.

error Using XPath locators is not recommended and can lead to fragile tests.

๋ฐ˜์‘ํ˜•

MAIN ๊ตฌํ˜„

์ €๋Š” ๊ตฌ๊ธ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ํ†ตํ•ด ์—ฌ๋Ÿฌ๊ฐœ์˜ ์ฑ„๋„ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๊ณ  ์žˆ์ง€๋งŒ, 1๊ฐœ ์ฑ„๋„์„ ํ…Œ์ŠคํŠธ ํ•˜๊ณ  ์‹ถ์„ ๊ฒฝ์šฐ ์•„๋ž˜์™€ ๊ฐ™์ด ์ˆ˜์ •ํ•˜์—ฌ ํ™•์ธํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

try:
    print("\nSTART...")

    #๊ตฌ๊ธ€ ์‹œํŠธ์—์„œ ์ฑ„๋„๋ฆฌ์ŠคํŠธ ๊ฐ€์ง€๊ณ ์™€์„œ ๋ฆฌ์ŠคํŠธ ์ €์žฅ
    print("\๊ตฌ๊ธ€ ์—ฐ๋™ํ•˜์—ฌ ๊ณต์œ  ์ฑ„๋„ ์ •๋ณด ์ €์žฅ")
    googlelib()
    print("\n\์ €์žฅ ์„ฑ๊ณต")
    
    defaultMain()

    #๊ฐ ์ฑ„๋„ ๋ณ„ ์‹ ๊ทœ ๋ณด๋“œ ๊ฐ€์ ธ์˜ค๊ธฐ
    print("\์ฑ„๋„๋ณ„ ์‹ ๊ทœ๋ณด๋“œ ๊ฐ€์ ธ์˜ค๊ธฐ")    
    for i in range(len(channel_list)) :
        newBoard(channel_list[i])
    print("\n\์‹ ๊ทœ ๋ณด๋“œ ์™„๋ฃŒ")
    
    print("\๊ตฌ๊ธ€ ์‹œํŠธ์— ๊ฐ’ ์ €์žฅ")
    updateBoardList()
    print("\๋ณด๋“œ ์ •๋ณด ๋งํฌ ์ €์žฅ ์™„๋ฃŒ")

finally:     
    driver.quit()
    print("\nEND...")

*1๊ฐœ์˜ ์ฑ„๋„ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ

try:
	#๊ฐ ์ฑ„๋„ ๋ณ„ ์‹ ๊ทœ ๋ณด๋“œ ๊ฐ€์ ธ์˜ค๊ธฐ
    print("\์ฑ„๋„๋ณ„ ์‹ ๊ทœ๋ณด๋“œ ๊ฐ€์ ธ์˜ค๊ธฐ")    
    newBoard("์ฑ„๋„๋ช…")
    print("\n\์‹ ๊ทœ ๋ณด๋“œ ์™„๋ฃŒ")
    
finally:     
    driver.quit()
    print("\nEND...")

์—ฌ๋Ÿฌ๊ฐœ์˜ ์ฑ„๋„์˜ ์‹ ๊ทœ๋ณด๋“œ๋ฅผ ๊ฐ€์ ธ์˜ฌ ๋•Œ ๊ตฌ๊ธ€ ์Šคํ”„๋ ˆ๋“œ์‹œํŠธ๋ฅผ ํ™œ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ์ถ”๊ฐ€ ์ ์ธ ๋ถ€๋ถ„์ด์˜ค๋‹ˆ, ํ•„์š”์‹œ ์‚ฌ์šฉํ•˜์…”์š”.

 

๊ตฌ๊ธ€ ์Šคํ”„๋ ˆ๋“œ ์‹œํŠธ๋ฅผ ์ด์šฉํ•˜์—ฌ ์นด์นด์˜ค๋ทฐ ์ฑ„๋„๋ช… ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ

์ €๋Š” ๊ตฌ๊ธ€ ์Šคํ”„๋ ˆ๋“œ ์‹œํŠธ์— ์ด N๊ฐœ์˜ ์ฑ„๋„๋ช…์ด ๊ธฐ์žฌ๋˜์–ด ์žˆ์–ด ๊ทธ ์ •๋ณด๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์นด์นด์˜ค๋ทฐ ์ž๋™ํ™” ํ”„๋กœ๊ทธ๋žจ์„ ๊ตฌํ˜„ ์ค‘์ž…๋‹ˆ๋‹ค.

def googlelib():
    # ๊ตฌ๊ธ€ ์Šคํ”„๋ ˆ๋“œ ์‹œํŠธ ์—ฐ๋™ , ๊ฐœ์ธ ์ •๋ณด์ด๋ฏ€๋กœ ํ•„์š”์— ๋”ฐ๋ผ ์‘์šฉํ•˜์—ฌ ์‚ฌ์šฉ
    # google platform ์ธ์ฆ key file
    json_file_name = info["keyFile"]
    gc =  gspread.service_account(filename=json_file_name)

    #๋ฆฌ์ŠคํŠธ ๋ถˆ๋Ÿฌ์˜ฌ URL
    doc = gc.open_by_url(info["channel_list_doc"])
    worksheet = doc.worksheet(info["docName"])
    tempName = worksheet.range(info["member_kName"])
    tempURL = worksheet.range(info["ch_address"])


    for i in range(len(tempName)):
        if i > 0 and tempName[i].value !='' :
            channel_list.append(tempName[i].value)


    for i in range(len(tempURL)):
        if i > 0 and tempURL[i].value !='' :
            url_parse.append(tempURL[i].value)
    

    print("\์ฑ„๋„: ", channel_list)
    print("\n ์ฑ„๋„๋งํฌ : ", url_parse)

 

๊ธฐํƒ€ ํ•„์š”ํ•œ  ํ•จ์ˆ˜

* remove_emoji ํ•จ์ˆ˜์™€ deEmojify ์ค‘ ๋ญ ์‚ฌ์šฉํ• ์ง€๋Š” ์ข€ ๋” ํ™•์ธ ํ•„์š”

๊ธ€์ž์— ์ด๋ชจ์ง€ ์ง€์šฐ๊ธฐ

def remove_emoji(text):
    return emoji.replace_emoji(text,replace='')
def deEmojify(text):
    regrex_pattern = re.compile(pattern = "["
        u"\U0001F600-\U0001F64F"  # emoticons
        u"\U0001F300-\U0001F5FF"  # symbols & pictographs
        u"\U0001F680-\U0001F6FF"  # transport & map symbols
        u"\U0001F1E0-\U0001F1FF"  # flags (iOS)
                           "]+", flags = re.UNICODE)
    return regrex_pattern.sub(r'',text)

์Šคํฌ๋ฆฐ ์‚ฌ์ด์ฆˆ ๋ถˆ๋Ÿฌ์™€์„œ swipe ํ•˜๋Š” ํ•จ์ˆ˜

def board_swipe() :
        #scroll size
        deviceSize = driver.get_window_size()
        screenWidth = deviceSize['width']
        screenHeight = deviceSize['height']
        startx = screenWidth / 2
        endx = screenWidth / 2
        endy = screenHeight * 2 / 9
        starty = screenHeight * 8 / 9

        print("start x :" , startx, " start y" , starty , "/end x ", endx , " end y ", endy)
        driver.swipe(start_x=startx,start_y=starty,end_x=endx,end_y=endy)

ํ•ญ์ƒ ์นด์นด์˜คํ†ก ์นœ๊ตฌ ํƒญ์—์„œ ๊ฒ€์ƒ‰ํ•˜๊ธฐ

def defaultMain() :
    #์ฑ„๋„ ๊ฒ€์ƒ‰ ๋ฒ„ํŠผ 
    sleep(LOADING_WAIT_TIME)

    ele = driver.find_element(By.XPATH, value ='//android.widget.RelativeLayout[@content-desc="์นœ๊ตฌ ํƒญ"]')
    ele.click()

    sleep(LOADING_WAIT_TIME)


    ele = driver.find_element(By.XPATH, value='//android.widget.TextView[@content-desc="๊ฒ€์ƒ‰ ๋ฒ„ํŠผ"]')
    ele.click()

    board_title_list.append("๋ณด๋“œ ์ œ๋ชฉ")
    board_url_list.append("๋ณด๋“œ ๋งํฌ")

    sleep(LOADING_WAIT_TIME)

๊ตฌ๊ธ€ ์Šคํ”„๋ ˆ๋“œ ์‹œํŠธ์— ๊ฐ ์ฑ„๋„๋ณ„ ๋ณด๋“œ ์ •๋ณด ์—…๋กœ๋“œํ•˜๊ธฐ

def updateBoardList() :
    json_file_name = info["keyFile"]
    gc =  gspread.service_account(filename=json_file_name)
   
    doc = gc.open_by_url(info["channel_list_doc"])
    worksheet = doc.worksheet(info["docName_update"])

    worksheet.clear()

    worksheet.insert_cols([board_title_list], col=1, value_input_option='RAW')
    worksheet.insert_cols([board_url_list], col=2, value_input_option='RAW')

์นด์นด์˜คํ†ก ๋ณด๋“œ ์‹œ๊ฐ„ ์ถ”์ถœ("์ผ ์ „"์ด ์•„๋‹Œ ์• ๋“ค์€ ์ˆซ์ž๋งŒ ์ถ”์ถœํ•˜๊ธฐ)

def replaceTime(text) :
    
    reTime = text.replace("์‹œ๊ฐ„ ์ „","")
    reTime = reTime.replace("๋ถ„ ์ „","")
    reTime = reTime.replace("์ˆ˜์ •","")
    reTime = reTime.replace(" ", "")

    return reTime

Python ์†Œ์Šค๊ฐ€ ์ค€๋น„๊ฐ€ ๋‹ค ๋˜์—ˆ๋‹ค๋ฉด, Appium ์„œ๋ฒ„๋ฅผ ๊ตฌ๋™ํ•œ ํ›„์— ์‹คํ–‰ ์‹œ์ผœ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

[์นด์นด์˜ค๋ทฐ ์ž๋™ํ™”] ์นด๋ทฐ ๊ด€๋ฆฌ ์ž๋™ํ™”๋ฅผ ์œ„ํ•œ appium ์‚ฌ์šฉ ๋ง›๋ณด๊ธฐ 1๋‹จ๊ณ„

์˜ˆ๋ž‘์ด๊ฐ€ ์ด๋Ÿฐ ํ…Œ์ŠคํŠธ ์ž๋™ํ™” ํ”„๋กœ๊ทธ๋žจ์ด ์žˆ๋‹ค๋Š” ๊ฑธ ์•Œ๋ ค์ค˜์„œ ์ ‘ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒ˜์Œ ํ•ด๋ณด๋Š” ๊ฒƒ์ด๋ผ์„œ ๋‚ฏ์„ค์—ˆ์ง€๋งŒ, ๋‹ค๋ฅธ ์–ธ์–ด๋“ค์ฒ˜๋Ÿผ ์ฒซ ์…‹ํŒ…๋งŒ ์ž˜ํ•ด๋ณด๋ฉด ๋‹ค ๋น„์Šทํ•˜๊ณ  ๊ฒฐ๊ตญ์—” python์œผ๋กœ ์ฝ”๋”ฉ

odaily.tistory.com

 

9์›” 17์ผ ์†Œ์Šค๋ฅผ ์กฐ๊ธˆ ์—…๊ทธ๋ ˆ์ด๋“œ ํ•˜์—ฌ ๋ณด๋“œ ๋งํฌ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ์— ์„ฑ๊ณตํ–ˆ์Šต๋‹ˆ๋‹ค. swipe๋ฅผ ํ•ด๋„, ๋งํฌ๊ฐ€ ์ค‘๋ณต๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์–ด unique๋กœ ํ•œ๋ฒˆ ๋” ์—‘์…€์—์„  ๊ฑธ๋Ÿฌ๋‚ด์„œ ์‚ฌ์šฉ ํ•˜๊ณ  ์žˆ๋‹ต๋‹ˆ๋‹ค. ํ•œ 90% ๋งŒ์กฑ๋„๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒƒ ๊ฐ™์•„์š”. ๋ฌธ์˜ ์‚ฌํ•ญ์€ ๋Œ“๊ธ€ ๋ถ€ํƒ๋“œ๋ ค์š”

๋™์ž‘ ์˜์ƒ

์˜์ƒ ์† ์ฒ˜๋Ÿผ ๋ณด๋“œ ๋งํฌ๋ฅผ ๋ณต์‚ฌํ•˜๋ฉด ์œ„ ์‚ฌ์ง„ ์ฒ˜๋Ÿผ ๊ตฌ๊ธ€ ์Šคํ”„๋ ˆ๋“œ ์‹œํŠธ์— ์—…๋ฐ์ดํŠธ ํ•ฉ๋‹ˆ๋‹ค. ํ˜„์žฌ ๋ฌด๋ฃŒ๋กœ ๊ฐ ์‚ฌ์ดํŠธ๋ณ„ ํ‚ค์›Œ๋“œ๋ฅผ ๋ชจ์•„๋‘” ์›นํŽ˜์ด์ง€๋ฅผ ์ œ๊ณตํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ๋ทฐ ์ถ”์ฒœํ‚ค์›Œ๋“œ๋„ ์—…๋ฐ์ดํŠธ ํ•ด์•ผ๊ฒ ๋‹จ ์ƒ๊ฐ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ๋ชจ๋ฐ”์ผ๋„ ์ปจํŠธ๋กค ํ•  ์ˆ˜ ์žˆ์–ด์„œ ๋„ˆ๋ฌด ์ข‹๋„ค์š”.

์ด๋ ‡๊ฒŒ ๊ฐ€์ ธ์˜จ ์นœ๊ตฌ๋œ ์ฑ„๋„์˜ ์ •๋ณด๋ฅผ ํ•œ๋ฒˆ์— ๋ชจ์•„ ๋ณผ ์ˆ˜ ์žˆ์–ด์„œ ์ข‹๋„ค์š”. ํ‹ฐ์Šคํ† ๋ฆฌ ๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑ ์‹œ์—๋„ ์ ๊ทน ๋ฐ˜์˜ํ•ด๋ด์•ผ๊ฒ ์–ด์š”. ์˜ˆ๋ฅผ ๋“ค๋ฉด ์ข‹์•„์š”๊ฐ€ ๋งŽ์ด ๋ˆŒ๋ฆฐ ์ฝ˜ํ…์ธ ๋Š” ์–ด๋–ค๊ฒŒ ์žˆ๋Š”์ง€ ์ œ ์นœ๊ตฌ ์ฑ„๋„ ์ค‘ Top5๋ฅผ ์„ ๋ณ„ํ•˜๊ฑฐ๋‚˜ ํ•˜๋Š”๊ฑฐ์ฃ !)

 

 

 

 

[๋ชจ๋ฐ”์ผ ๋งคํฌ๋กœ] ๋‰ด์Šค URL ํด๋ฆญ ๋ฐ ๋ชจ๋ฐ”์ผ ํ™”๋ฉด ์บก์ณ ์ž๋™ํ™”, ๋ชจ๋ฐ”์ผ ์Šคํฌ๋ฆฝ์บก์ณ, selenium + appium + sc

appium์„ ์•Œ๊ณ  ๋ถ€ํ„ฐ๋Š” ๋ชจ๋ฐ”์ผ์—์„œ ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ๋“ค์ด ๋งŽ์•„์กŒ์–ด์š”. ์ฒ˜์Œ ๋ฐฐ์šธ ๋• ๋ชฐ๋ž๋Š”๋ฐ ํ•˜๋‹ค๋ณด๋‹ˆ, ๋ชจ๋ฐ”์ผ ๋งคํฌ๋กœ๋Š” ๋‹ค๋“ค ์ด๊ฑธ๋กœ ๊ตฌํ˜„ํ•˜๊ฒ ๊ตฌ๋‚˜ ๋ผ๋Š” ์ƒ๊ฐ์„ ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ต๋‹ˆ๋‹ค. ๋ผ๋–ผ๋Š” ์ด๋Ÿฐ๊ฒŒ ์žˆ์—ˆ

odaily.tistory.com

 

๋Œ“๊ธ€