Beispiel #1
0
 def insta_jungdok(self, tag, click_num):
     self.search_tag(tag)
     self.select_picture()
     for i in range(click_num):
         self.press_like()
         pw.key_press_once("right_arrow")
         time.sleep(3)
Beispiel #2
0
    def select_picture(self):
        # 탭 키를 20번정도 누르기
        for i in range(12):
            pw.key_press_once("tab")

        # 엔터 누르기
        pw.key_press_once("enter")
    def scrap_news(self, id, ps, keyword):
        self.driver.get(self.search_url + keyword)
        time.sleep(5)

        # 클릭할 좌표를 지정합니다.
        location = (585, 302)

        # 화면을 클릭합니다.
        pw.click(location)

        # Ctrl + A를 누릅니다.
        pw.ctrl_a()
        time.sleep(1)

        # Ctrl + C를 누릅니다.
        pw.ctrl_c()
        # Ctrl + C를 누릅니다.
        pw.ctrl_c()
        # Ctrl + C를 누릅니다.
        pw.ctrl_c()
        # Ctrl + C를 누릅니다.
        pw.ctrl_c()
        time.sleep(3)

        # 클립보드의 내용물을 뽑아옵니다.
        self.news_text = pc.paste()

        # 뉴스 텍스트를 스플릿합니다.
        self.splt = self.news_text.split("\r\n\r\n")[2:11]

        # 트위터에 접속합니다.
        self.driver.get("https://twitter.com/login")
        time.sleep(5)
        # 아이디를 입력합니다.
        pw.typing(id)
        # 탭 키를 칩니다.
        pw.key_press_once("tab")
        # 비밀번호를 입력합니다.
        pw.typing(ps)
        # 엔터키를 칩니다.
        pw.key_press_once("enter")
        time.sleep(5)

        for el in self.splt:
            # 트위터에 글을 올립니다.
            # 게시물 작성 페이지로 이동
            self.driver.get("https://twitter.com/intent/tweet")
            time.sleep(2)
            # 내용물 입력 한글일 경우는 type_in
            pw.type_in(el)
            time.sleep(1)

            # Ctrl + Enter 누르기
            pw.key_on("control")
            pw.key_on("enter")
            pw.key_on("control")
            pw.key_off("enter")

            time.sleep(10)
Beispiel #4
0
 def select_picture(self):
     # 탭 키를 여러번 눌러 사진으로 이동하는 전략을 사용합니다.
     # 검색 결과에 예시로 나오는 '관련 해시태그' 개수가 매번 다르므로
     # 첫 번째 사진을 고르려면 매번 다른 회수의 탭을 눌러야 합니다.
     # 차라리 첫 몇개는 버리고 충분히 넉넉하게 탭을 누릅시다.
     for i in range(20):
         pw.key_press_once("tab")
     pw.key_press_once("enter")
     # 잠시 기다립니다.
     time.sleep(5)
 def login(self, id, ps):
     # 아이디를 입력합니다.
     pw.typing(id)
     # tab 키를 눌러줍시다. 대부분의 사이트에서 암호창으로 이동합니다.
     pw.key_press_once("tab")
     # 비밀번호를 마저 입력합니다.
     pw.typing(ps)
     # 엔터키를 눌러줍니다. 대부분의 사이트에서 로그인이 실행됩니다.
     pw.key_press_once("enter")
     # 로딩이 오래 걸릴 수 있으니 잠시 대기합니다.
     time.sleep(5)
Beispiel #6
0
 def capture_pictures(self, directory, num):
     # 반복 회수를 결정하기 위한 변수입니다.
     count = num
     # count 가 0이 될때까지 반복합니다.
     while count != 0:
         # 카운트를 한 개씩 깎아내립니다.
         # num이 -1인 경우 계속 0보다 작아지기만 하고 0이 되지는 않으므로 영원히 실행됩니다.
         count -= 1
         # 스크린샷을 땁니다.
         self.save_screenshot(directory + "/" + str(time.time()) + ".png")
         # 다음 게시물로 넘어갑니다. 오른쪽 화살표버튼만 누르면 됩니다.
         pw.key_press_once("right_arrow")
         # 로딩을 위해 5초가량 기다립니다.
         time.sleep(5)
 def press_like_buttons(self, num):
     # 반복 회수를 결정하기 위한 변수입니다.
     count = num
     # count 가 0이 될때까지 반복합니다.
     while count != 0:
         # 카운트를 한 개씩 깎아내립니다.
         # num이 -1인 경우 계속 0보다 작아지기만 하고 0이 되지는 않으므로 영원히 실행됩니다.
         count -= 1
         # 좋아요 버튼을 찾아 클릭을 시도합니다.
         # self.press_like() 함수는 클릭을 시도하고 동시에 성공여부를 리턴하므로 if문 안에 넣어줍니다.
         if not self.press_like():
             # 화면에서 좋아요 버튼을 찾는 것을 실패한 경우 에러메시지를 출력하고 종료합니다.
             print("Cannot find like button. Please check " + self.like_button + " file.")
             exit(1)
         # 좋아요 버튼 클릭에 성공했으면 다음 게시물로 넘어갑니다. 오른쪽 화살표버튼만 누르면 됩니다.
         pw.key_press_once("right_arrow")
         # 로딩을 위해 5초가량 기다립니다.
         time.sleep(5)
Beispiel #8
0
    def login(self, id, ps):
        # 로그인 페이지로 이동
        self.driver.get("https://www.instagram.com/accounts/login")

        # 로그인
        time.sleep(5)
        pw.key_press_once("tab")
        pw.typing(id)
        pw.key_press_once("tab")
        pw.typing(ps)
        pw.key_press_once("enter")
        time.sleep(5)
Beispiel #9
0
 def login(self, id, ps):
     # 로그인 페이지로 이동합니다.
     self.driver.get("https://www.instagram.com/accounts/login")
     # 로딩이 오래 걸릴 수 있으니 잠시 대기합니다.
     time.sleep(5)
     # 탭 키를 한 번 누르면 아이디 입력창으로 이동합니다.
     pw.key_press_once("tab")
     # 아이디를 입력합니다.
     pw.typing(id)
     # 탭 키를 한 번 눌러 비밀번호 입력창으로 이동합니다.
     pw.key_press_once("tab")
     # 비밀번호도 입력합니다.
     pw.typing(ps)
     # 엔터키를 눌러 로그인을 시도합니다.
     pw.key_press_once("enter")
     # 로딩이 완료되기까지 충분히 기다려줍니다.
     time.sleep(10)
Beispiel #10
0
 def refresh(self):
     pw.key_press_once("f5")
Beispiel #11
0
time.sleep(3)

# 클립보드의 내용물을 뽑아옵니다.
news_text = pc.paste()

# 뉴스 텍스트를 스플릿합니다.
splt = news_text.split("\r\n\r\n")[2:-1]

# 트위터에 접속합니다
driver.get("https://twitter.com/login")

time.sleep(5)
# 아이디를 입력합니다
pw.typing(id)
# 탭을 입력합니다
pw.key_press_once("tab")
# 비밃번호를 입력합니다
pw.typing(ps)
# 엔터를 입력합니다
pw.key_press_once("enter")
# 5초를 기다립니다
time.sleep(5)

for el in splt:

    # 트위터에 글을 올립니다.
    # 게시물 작성페이지로 이동
    driver.get("https://twitter.com/intent/tweet")
    time.sleep(5)
    pw.type_in(el)
    time.sleep(2)