-
Notifications
You must be signed in to change notification settings - Fork 0
/
instargram1.R
109 lines (78 loc) · 3.78 KB
/
instargram1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#인스타그램 좋아요, 팔로우, 댓글달기 자동화
#findElement 가 바뀌수도 있으니 주의
library(RSelenium)
remDr <- remoteDriver(remoteServerAddr="localhost" , port="포트번호" , browserName="chrome")
remDr$open()
remDr$navigate("https://www.instagram.com/")
Sys.sleep(3)
#ID
id <- remDr$findElement(using="css" , "#loginForm > div > div:nth-child(1) > div > label > input")
id$clickElement()
id$sendKeysToElement(list("아이디"))
#PW
pw <- remDr$findElement(using="css" , "#loginForm > div > div:nth-child(2) > div > label > input")
pw$clickElement()
pw$sendKeysToElement(list("비밀번호",key="enter"))
Sys.sleep(5)
#로그인 정보를 저장하시겠어요? -> 나중에 하기
late <- remDr$findElement(using="css" , "#react-root > section > main > div > div > div > div > button")
late$clickElement()
#알림 설정 -> 나중에 하기
notice <- remDr$findElement(using="css" , "body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.HoLwm")
notice$clickElement()
#해쉬태그 글
search <- remDr$findElement(using="css" , "#react-root > section > nav > div._8MQSO.Cx7Bp > div > div > div.LWmhU._0aCwM > input")
search$sendKeysToElement(list("좋아요반사",key="enter"))
#해쉬태그 검색
click <- remDr$findElement(using="css" , "#react-root > section > nav > div._8MQSO.Cx7Bp > div > div > div.LWmhU._0aCwM > div.drKGC > div > a:nth-child(1) > div > div > div.uyeeR > span")
click$clickElement()
#-------------------------------------------------
# 선팔 & 좋아요 & 댓글 창 옆으로
post_click <- remDr$findElement(using="css" , "#react-root > section > main > article > div:nth-child(3) > div > div:nth-child(1) > div:nth-child(1) > a > div > div._9AhH0")
post_click$clickElement()
#1~10 까지 반복
for(i in c(1:10)){
Sys.sleep(6)
#좋아요
like <- remDr$findElements(using="css" , ".fr66n")
if(length(like) == 0){
comment_click <- remDr$findElement(using="css" , "body > div._2dDPU.CkGkG > div.EfHg9 > div > div > a._65Bje.coreSpriteRightPaginationArrow")
comment_click$clickElement()
}else{
like <- remDr$findElement(using="css" , ".fr66n")
like$clickElement()
Sys.sleep(2)
#팔로우
follow <- remDr$findElement(using="css" , "body > div._2dDPU.CkGkG > div.zZYga > div > article > header > div.o-MQd.z8cbW > div.PQo_0.RqtMr > div.bY2yH > button")
follow$clickElement()
unfollow <- remDr$findElements(using="css" , "button.aOOlW.HoLwm")
if(length(unfollow) == 1){
cancel_unfollow <- remDr$findElement(using="css" , "body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.HoLwm")
cancel_unfollow$clickElement()
Sys.sleep(3)
comment_click <- remDr$findElement(using="css" , "body > div._2dDPU.CkGkG > div.EfHg9 > div > div > a._65Bje.coreSpriteRightPaginationArrow")
comment_click$clickElement()
}else{
Sys.sleep(6)
#댓글
comment <- remDr$findElements(using="css" , "form > textarea")
if(length(comment) == 0){
comment_click <- remDr$findElement(using="css" , "body > div._2dDPU.CkGkG > div.EfHg9 > div > div > a._65Bje.coreSpriteRightPaginationArrow")
comment_click$clickElement()
}else{
comment <- remDr$findElement(using="css" , "form > textarea")
comment$clickElement()
comment2 <- remDr$findElement(using="css" , ".Ypffh")
comment2$sendKeysToElement(list("좋아요 꾹 누르고 갑니다~"))
Sys.sleep(3)
#댓글 달기
comment_click <- remDr$findElement(using="css" , "section.sH9wk._JgwE > div > form > button")
comment_click$clickElement()
Sys.sleep(5)
}
comment_click <- remDr$findElement(using="css" , "body > div._2dDPU.CkGkG > div.EfHg9 > div > div > a._65Bje.coreSpriteRightPaginationArrow")
comment_click$clickElement()
Sys.sleep(1)
}
}
}