質問編集履歴
1
colabにてgoogleアカウントへのログインを試みた結果のエラーを記載。
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,3 +25,49 @@
|
|
25
25
|
実行環境以下の通りです。
|
26
26
|
windows10(ローカル)
|
27
27
|
google colab
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
追記
|
32
|
+
colabのseleniumにてgoogleアカウントへのログインを試してみました。
|
33
|
+
メールアドレスの入力をし、「次へ」ボタンをクリックするまではできるものの、
|
34
|
+
遷移後ページで画像のようなページが表示されてしまい、ログインをブロックされてしまいます。
|
35
|
+
その際のサンプルコードを以下に記載いたします。
|
36
|
+
```python
|
37
|
+
!pip install selenium
|
38
|
+
!apt-get update
|
39
|
+
!apt install chromium-chromedriver
|
40
|
+
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
|
41
|
+
|
42
|
+
from selenium import webdriver
|
43
|
+
from selenium.webdriver.common.by import By
|
44
|
+
import time
|
45
|
+
|
46
|
+
options = webdriver.ChromeOptions()
|
47
|
+
options.add_argument('--headless')
|
48
|
+
options.add_argument('--no-sandbox')
|
49
|
+
options.add_argument('--disable-dev-shm-usage')
|
50
|
+
browser = webdriver.Chrome('chromedriver', options = options)
|
51
|
+
browser.implicitly_wait(3)
|
52
|
+
|
53
|
+
mailaddress = 'xxx@gmail.com'
|
54
|
+
password = 'abcde'
|
55
|
+
|
56
|
+
browser.get('https://accounts.google.com/v3/signin/identifier?dsh=S-1728033197%3A1667719904448834&continue=https%3A%2F%2Ftakeout.google.com%2F%3Fhl%3Dja&followup=https%3A%2F%2Ftakeout.google.com%2F%3Fhl%3Dja&hl=ja&osid=1&passive=1209600&flowName=GlifWebSignIn&flowEntry=ServiceLogin&ifkv=ARgdvAtuz0mFizH6_aYzDaVMfEdqdoEHh0P5jiZZ6W7ZsolkV2-v7al8G_9cDXTQTl2skc8N-RZoag')
|
57
|
+
inputMail = browser.find_element(by = By.ID, value = 'identifierId')
|
58
|
+
inputMail.send_keys(mailaddress)
|
59
|
+
|
60
|
+
mailNextBotton = browser.find_element(by = By.XPATH, value = '/html/body/div[1]/div[1]/div[2]/div/c-wiz/div/div[2]/div/div[2]/div/div[1]/div/div/button')
|
61
|
+
time.sleep(2)
|
62
|
+
mailNextBotton.click()
|
63
|
+
time.sleep(10)
|
64
|
+
# ↑まではエラーなく実行できます。
|
65
|
+
# ↓直後の inputPass で NoSuchElementException のエラーが出てしまいます。
|
66
|
+
inputPass = browser.find_element(by = By.XPATH, value = '/html/body/div[1]/div[1]/div[2]/div/c-wiz/div/div[2]/div/div[1]/div/form/span/div[1]/div[1]/div/div/div/div/div[1]/div/div[1]/input')
|
67
|
+
inputPass.send_keys(password)
|
68
|
+
passNextBotton = browser.find_element(by = By.XPATH, value = '/html/body/div[1]/div[1]/div[2]/div/c-wiz/div/div[2]/div/div[2]/div/div[1]/div/div/button/span')
|
69
|
+
time.sleep(2)
|
70
|
+
passNextBotton.click()
|
71
|
+
```
|
72
|
+
|
73
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-11-06/5e05bf99-013f-4f51-9088-24e4b43350e8.png)
|