質問編集履歴

1

誤字

2021/03/18 07:46

投稿

_154Mono
_154Mono

スコア0

test CHANGED
File without changes
test CHANGED
@@ -91,183 +91,3 @@
91
91
 
92
92
 
93
93
  ### 補足情報(FW/ツールのバージョンなど)
94
-
95
-
96
-
97
- 全文コード
98
-
99
- ```
100
-
101
- import pyautogui
102
-
103
- import requests
104
-
105
- import re
106
-
107
- import sys
108
-
109
- from bs4 import BeautifulSoup as bs
110
-
111
- from selenium import webdriver
112
-
113
- from time import sleep
114
-
115
-
116
-
117
- xpath_list = ['//*[@id="root"]/div/div[2]/div/div/div[2]/main/div/div[1]/div/div/div/div/div/div[5]/div[1]/div[2]/div[2]/span',
118
-
119
- '//*[@id="root"]/div/div[2]/div/div/div[2]/main/div/div[1]/div/div/div/div/div/div[6]/div[1]/div[2]/div[2]/span',
120
-
121
- '//*[@id="root"]/div/div[2]/div/div/div[2]/main/div/div[1]/div/div/div/div/div/div[7]/div[1]/div[2]/div[2]/span',
122
-
123
- '//*[@id="root"]/div/div[2]/div/div/div[2]/main/div/div[1]/div/div/div/div/div/div[8]/div[1]/div[2]/div[2]/span',
124
-
125
- '//*[@id="root"]/div/div[2]/div/div/div[2]/main/div/div[1]/div/div/div/div/div/div[9]/div[1]/div[2]/div[2]/span',
126
-
127
- '//*[@id="root"]/div/div[2]/div/div/div[2]/main/div/div[1]/div/div/div/div/div/div[10]/div[1]/div[2]/div[2]/span',
128
-
129
- '//*[@id="root"]/div/div[2]/div/div/div[2]/main/div/div[1]/div/div/div/div/div/div[11]/div[1]/div[2]/div[2]/span',
130
-
131
- '//*[@id="root"]/div/div[2]/div/div/div[2]/main/div/div[1]/div/div/div/div/div/div[12]/div[1]/div[2]/div[2]/span',
132
-
133
- ]
134
-
135
-
136
-
137
-
138
-
139
- MailAdress='********@gmail.com'
140
-
141
- PassWord='*******'
142
-
143
-
144
-
145
-
146
-
147
- #chromeを起動して指定のURLに移動
148
-
149
- driver = webdriver.Chrome('C:\Users\********\Desktop\chromedriver')
150
-
151
- error_flag = False
152
-
153
- target_url = 'https://app.musubu.in/sign_in?_ga=2.33374014.187283904.1615714378-1319620580.1615714378'
154
-
155
- driver.get(target_url)
156
-
157
- sleep(5)
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
- #ログインを行う
168
-
169
- if error_flag is False:
170
-
171
- try:
172
-
173
- username_input=driver.find_element_by_name("email")
174
-
175
- username_input.send_keys(MailAdress)
176
-
177
- sleep(1)
178
-
179
-
180
-
181
- password_input = driver.find_element_by_name("password")
182
-
183
- password_input.send_keys(PassWord)
184
-
185
- sleep(1)
186
-
187
-
188
-
189
- username_input.submit()
190
-
191
- sleep(1)
192
-
193
-
194
-
195
-
196
-
197
- except Exception:
198
-
199
- print('メール名、パスワード入力持にエラーが発生しました。')
200
-
201
- error_flg =True
202
-
203
-
204
-
205
- #事業内容キーワードをクリックして、指定したキーワードを入力
206
-
207
- element = driver.find_element_by_xpath('//*[@id="root"]/div/div[2]/div/div/div[2]/aside/div/div[1]/div/div/div/div[2]/div/div/div/div[4]/button[2]')
208
-
209
- element.click()
210
-
211
-
212
-
213
- serch = driver.find_element_by_xpath('//*[@id="modal-root"]/div[6]/div/div/div/div[2]/div/div[1]/div/div[2]/div/input')
214
-
215
- serch.send_keys('Webマーケティング')
216
-
217
- sleep(2)
218
-
219
-
220
-
221
- #チェックボックスをクリックし検索する
222
-
223
- select= driver.find_element_by_xpath('/html/body/div[1]/div/div[3]/div[1]/div[6]/div/div/div/div[2]/div/div[2]/div[1]/div[2]/div/label/input')
224
-
225
- select.click()
226
-
227
- sleep(1)
228
-
229
-
230
-
231
- button_click = driver.find_element_by_xpath('//*[@id="modal-root"]/div[6]/div/div/div/div[3]/div[2]/button[2]')
232
-
233
- button_click.click()
234
-
235
- sleep(1)
236
-
237
-
238
-
239
- while True:
240
-
241
- for i in xpath_list:
242
-
243
- look = driver.find_element_by_xpath(i)
244
-
245
- look.click()
246
-
247
- sleep(2)
248
-
249
-
250
-
251
- elem_url=[]
252
-
253
- elems = driver.find_elements_by_css_selector(".ButtonNormal-sc-150s4md-0.hYHvFi.mr-10")
254
-
255
- for elem in elems:
256
-
257
- elem_url.append(elem.get_attribute("href"))
258
-
259
- sleep(1)
260
-
261
- print(elem_url)
262
-
263
- sleep(1)
264
-
265
-
266
-
267
- back = driver.find_element_by_css_selector('.Drawer__CloseButton-ui4eii-0.gGfjsd')
268
-
269
- back.click()
270
-
271
- sleep(2)
272
-
273
- ```