質問編集履歴
3
タイトル変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
特定のサイトへのログインができない
|
1
|
+
Seleniumで特定のサイトへのログインができない
|
test
CHANGED
File without changes
|
2
個人情報が掲載されていたので修正した
test
CHANGED
File without changes
|
test
CHANGED
@@ -64,13 +64,16 @@
|
|
64
64
|
PW : ***
|
65
65
|
https://jmty.jp/my/posts
|
66
66
|
(.env) *** AutoPost % heroku run python app/loginTest.py
|
67
|
-
Running python app/loginTest.py on ⬢
|
67
|
+
Running python app/loginTest.py on ⬢ ***... up, run.4360 (Basic)
|
68
68
|
ID : ***
|
69
69
|
PW : ***
|
70
70
|
https://jmty.jp/users/sign_in
|
71
71
|
メールアドレスかパスワードが違います。
|
72
72
|
パスワードの再設定はこちら
|
73
73
|
```
|
74
|
+
|
75
|
+
ジモティーログインエラーの再現画面(実際はヘッドレスモードでの運用です)
|
76
|
+

|
74
77
|
|
75
78
|
### 試したこと
|
76
79
|
|
1
情報の変更、追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -17,72 +17,59 @@
|
|
17
17
|
from selenium import webdriver
|
18
18
|
from selenium.webdriver.chrome.options import Options
|
19
19
|
from selenium.webdriver.common.by import By
|
20
|
-
from selenium.webdriver.chrome import service as fs
|
21
20
|
|
22
21
|
import pathlib
|
23
22
|
import time
|
24
|
-
import shutil
|
25
23
|
|
26
24
|
appPath = pathlib.Path.cwd() / 'app'
|
27
|
-
|
28
|
-
|
25
|
+
# appPath = '/AutoPost/app'
|
29
|
-
#CHROMEDRIVER = appPath / 'chromedriver_mac64' / 'chromedriver'
|
30
|
-
CHROMEDRIVER = '/app/.chromedriver/bin/chromedriver'
|
31
26
|
|
32
27
|
options = Options()
|
33
28
|
options.add_argument('--disable-gpu')
|
34
|
-
options.add_argument('--disable-extensions')
|
35
|
-
options.add_argument('--proxy-server="direct://"')
|
36
|
-
options.add_argument('--proxy-bypass-list=*')
|
37
|
-
options.add_argument('--start-maximized')
|
38
29
|
options.add_argument('--headless=new')
|
39
|
-
options.add_argument('--disable-de
|
30
|
+
options.add_argument('--disable-desktop-notifications')
|
40
|
-
options.add_argument("--
|
31
|
+
options.add_argument("--disable-extensions")
|
32
|
+
|
41
|
-
|
33
|
+
jmtyID = '***'
|
42
|
-
|
34
|
+
jmtyPW = '***'
|
43
35
|
|
44
36
|
try:
|
45
|
-
i
|
37
|
+
driver = webdriver.Chrome(options=options)
|
46
38
|
|
39
|
+
driver.get('https://jmty.jp/users/sign_in')
|
47
|
-
i
|
40
|
+
time.sleep(5)
|
41
|
+
IDForm = driver.find_element(By.CSS_SELECTOR, '#user_email')
|
42
|
+
PWForm = driver.find_element(By.CSS_SELECTOR, '#user_password')
|
43
|
+
IDForm.clear()
|
44
|
+
PWForm.clear()
|
45
|
+
IDForm.send_keys(jmtyID)
|
46
|
+
PWForm.send_keys(jmtyPW)
|
47
|
+
print('ID : ' + IDForm.get_attribute('value'))
|
48
|
+
print('PW : ' + PWForm.get_attribute('value'))
|
49
|
+
driver.find_element(By.CSS_SELECTOR, '#submit_button').click()
|
50
|
+
time.sleep(5)
|
48
51
|
|
49
|
-
driver = webdriver.Chrome(service=chrome_service, options=options)
|
50
|
-
|
51
|
-
driver.get('https://jmty.jp/users/sign_in')
|
52
|
-
time.sleep(3)
|
53
|
-
|
54
|
-
driver.find_element(By.CSS_SELECTOR, '#user_email').send_keys('...')
|
55
|
-
driver.find_element(By.CSS_SELECTOR, '#user_password').send_keys('...')
|
56
|
-
driver.find_element(By.CSS_SELECTOR, '#submit_button').click()
|
57
|
-
time.sleep(3)
|
58
|
-
if driver.current_url == 'https://jmty.jp/my/posts':
|
59
|
-
print('success')
|
60
|
-
else:
|
61
|
-
|
52
|
+
print(driver.current_url)
|
62
|
-
|
63
|
-
elif inputC == 2:
|
64
|
-
driver = webdriver.Chrome(service=chrome_service, chrome_options=options)
|
65
|
-
driver.get('chrome://version')
|
66
|
-
time.sleep(3)
|
67
|
-
print('executable path : ' + driver.find_element(By.CSS_SELECTOR, '#executable_path').text)
|
68
|
-
print('profile path : ' + driver.find_element(By.CSS_SELECTOR, '#profile_path').text)
|
69
|
-
|
70
|
-
elif inputC == 4:
|
71
|
-
driver = webdriver.Chrome(service=chrome_service, chrome_options=options)
|
72
|
-
driver.get('https://....herokuapp.com/admin/')
|
73
|
-
time.sleep(3)
|
74
|
-
|
53
|
+
if driver.find_elements(By.CSS_SELECTOR, '#main > div.system-message-component.alert > div'):
|
75
|
-
driver.find_element(By.CSS_SELECTOR, '#id_password').send_keys('...')
|
76
|
-
driver.find_element(By.CSS_SELECTOR, '#
|
54
|
+
print(driver.find_element(By.CSS_SELECTOR, '#main > div.system-message-component.alert > div').text)
|
77
|
-
time.sleep(3)
|
78
|
-
print(driver.find_element(By.CSS_SELECTOR, '#user-tools').text)
|
79
|
-
|
80
|
-
|
81
|
-
else:
|
82
|
-
driver = webdriver.Chrome(service=chrome_service, chrome_options=options)
|
83
55
|
|
84
56
|
finally:
|
85
57
|
driver.quit()
|
58
|
+
```
|
59
|
+
|
60
|
+
### 出力結果
|
61
|
+
```
|
62
|
+
(.env) *** AutoPost % python app/loginTest.py
|
63
|
+
ID : ***
|
64
|
+
PW : ***
|
65
|
+
https://jmty.jp/my/posts
|
66
|
+
(.env) *** AutoPost % heroku run python app/loginTest.py
|
67
|
+
Running python app/loginTest.py on ⬢ serene-fortress-94071... up, run.4360 (Basic)
|
68
|
+
ID : ***
|
69
|
+
PW : ***
|
70
|
+
https://jmty.jp/users/sign_in
|
71
|
+
メールアドレスかパスワードが違います。
|
72
|
+
パスワードの再設定はこちら
|
86
73
|
```
|
87
74
|
|
88
75
|
### 試したこと
|
@@ -120,6 +107,17 @@
|
|
120
107
|
gunicorn==20.1.0
|
121
108
|
selenium==4.8.0
|
122
109
|
|
110
|
+
### 追記(2/27 1:00)
|
111
|
+
|
112
|
+
一時自己解決にしましたが、思い違いで解決できていなかったので、編集して再投稿としました。
|
113
|
+
編集内容としては、
|
114
|
+
- ソースコードの簡略化
|
115
|
+
実際に、今まで調べてきて簡略化できるところや不要なところ、自分で色々なことを試す上で編集している箇所を示すため、ソースコードの中身を大幅に変更しました。
|
116
|
+
- 出力結果の掲示
|
117
|
+
エラーメッセージが出てないといえ、表示結果がないのは情報が足りないと思い追加しました。
|
118
|
+
|
119
|
+
の2点になります。よろしくお願いします。
|
120
|
+
|
123
121
|
---
|
124
122
|
|
125
123
|
こんなことでなんでつまづいているか情けなくなりますが、どなたかアドバイスいただけると嬉しいです。
|