質問編集履歴
1
教えていただいた方法を試した際に現状が変化したので、その部分を追加しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,46 +1,153 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
headlessブラウザを起動してスクレイピングをする。
|
3
3
|
|
4
|
+
よろしくお願いします。
|
5
|
+
|
4
6
|
### 発生している問題・エラーメッセージ
|
5
7
|
|
6
|
-
|
8
|
+
3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
|
7
9
|
Traceback (most recent call last):
|
8
|
-
File "test.py", line
|
10
|
+
File "test.py", line 23, in <module>
|
11
|
+
main()
|
12
|
+
File "test.py", line 16, in main
|
9
|
-
driver = webdriver.Chrome(chrome_options=options, executable_path="
|
13
|
+
driver = webdriver.Chrome(chrome_options=options, executable_path=executable_path, service_args=["--verbose", f"--log-path={log_path}"])
|
10
|
-
File "C:\
|
14
|
+
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
|
11
15
|
desired_capabilities=desired_capabilities)
|
12
|
-
File "C:\
|
16
|
+
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init__
|
13
17
|
self.start_session(desired_capabilities, browser_profile)
|
14
|
-
File "C:\
|
18
|
+
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session
|
15
19
|
response = self.execute(Command.NEW_SESSION, parameters)
|
16
|
-
File "C:\
|
20
|
+
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
|
17
21
|
self.error_handler.check_response(response)
|
18
|
-
File "C:\
|
22
|
+
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
|
19
23
|
raise exception_class(message, screen, stacktrace)
|
20
24
|
selenium.common.exceptions.WebDriverException: Message: unknown error: chrome failed to start
|
21
|
-
(Driver info: chromedriver=2.
|
25
|
+
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.3 x86_64)
|
22
26
|
|
27
|
+
|
28
|
+
【Chrome Driverのデバックログの内容】
|
29
|
+
[2.995][INFO]: COMMAND InitSession {
|
30
|
+
"capabilities": {
|
31
|
+
"alwaysMatch": {
|
32
|
+
"browserName": "chrome",
|
33
|
+
"goog:chromeOptions": {
|
34
|
+
"args": [ "--no-sandbox", "--disable-gpu", "--headless" ],
|
35
|
+
"extensions": [ ]
|
36
|
+
},
|
37
|
+
"platformName": "any"
|
38
|
+
},
|
39
|
+
"firstMatch": [ {
|
40
|
+
|
41
|
+
} ]
|
42
|
+
},
|
43
|
+
"desiredCapabilities": {
|
44
|
+
"browserName": "chrome",
|
45
|
+
"goog:chromeOptions": {
|
46
|
+
"args": [ "--no-sandbox", "--disable-gpu", "--headless" ],
|
47
|
+
"extensions": [ ]
|
48
|
+
},
|
49
|
+
"platform": "ANY",
|
50
|
+
"version": ""
|
51
|
+
}
|
52
|
+
}
|
53
|
+
[2.998][INFO]: Populating Preferences file: {
|
54
|
+
"alternate_error_pages": {
|
55
|
+
"enabled": false
|
56
|
+
},
|
57
|
+
"autofill": {
|
58
|
+
"enabled": false
|
59
|
+
},
|
60
|
+
"browser": {
|
61
|
+
"check_default_browser": false
|
62
|
+
},
|
63
|
+
"distribution": {
|
64
|
+
"import_bookmarks": false,
|
65
|
+
"import_history": false,
|
66
|
+
"import_search_engine": false,
|
67
|
+
"make_chrome_default_for_user": false,
|
68
|
+
"show_welcome_page": false,
|
69
|
+
"skip_first_run_ui": true
|
70
|
+
},
|
71
|
+
"dns_prefetching": {
|
72
|
+
"enabled": false
|
73
|
+
},
|
74
|
+
"profile": {
|
75
|
+
"content_settings": {
|
76
|
+
"pattern_pairs": {
|
77
|
+
"https://*,*": {
|
78
|
+
"media-stream": {
|
79
|
+
"audio": "Default",
|
80
|
+
"video": "Default"
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
},
|
85
|
+
"default_content_settings": {
|
86
|
+
"geolocation": 1,
|
87
|
+
"mouselock": 1,
|
88
|
+
"notifications": 1,
|
89
|
+
"popups": 1,
|
90
|
+
"ppapi-broker": 1
|
91
|
+
},
|
92
|
+
"password_manager_enabled": false
|
93
|
+
},
|
94
|
+
"safebrowsing": {
|
95
|
+
"enabled": false
|
96
|
+
},
|
97
|
+
"search": {
|
98
|
+
"suggest_enabled": false
|
99
|
+
},
|
100
|
+
"translate": {
|
101
|
+
"enabled": false
|
102
|
+
}
|
103
|
+
}
|
104
|
+
[3.000][INFO]: Populating Local State file: {
|
105
|
+
"background_mode": {
|
106
|
+
"enabled": false
|
107
|
+
},
|
108
|
+
"ssl": {
|
109
|
+
"rev_checking": {
|
110
|
+
"enabled": false
|
111
|
+
}
|
112
|
+
}
|
113
|
+
[3.512][INFO]: RESPONSE InitSession unknown error: chrome failed to start
|
114
|
+
[3.512][DEBUG]: Log type 'driver' lost 0 entries on destruction
|
115
|
+
[3.512][DEBUG]: Log type 'browser' lost 0 entries on destruction
|
116
|
+
|
23
117
|
### 該当のソースコード
|
24
|
-
Python
|
25
|
-
|
26
118
|
# -*- coding: utf-8 -*-
|
27
119
|
from selenium import webdriver
|
28
120
|
from selenium.webdriver.chrome.options import Options
|
121
|
+
import sys
|
29
122
|
|
123
|
+
def main():
|
124
|
+
print(sys.version)
|
30
|
-
options = Options()
|
125
|
+
options = Options()
|
31
|
-
options.
|
126
|
+
options.add_argument('--no-sandbox')
|
127
|
+
options.add_argument('--disable-gpu')
|
32
|
-
options.add_argument('--headless')
|
128
|
+
#options.add_argument('--headless')
|
129
|
+
options.add_argument('--incognito')
|
130
|
+
options.add_argument('--disable-extensions')
|
131
|
+
log_path = r"C:\selenium\chromedriver.log"
|
132
|
+
executable_path = 'C:\selenium\chromedriver.exe'
|
33
|
-
driver = webdriver.Chrome(chrome_options=options, executable_path="
|
133
|
+
driver = webdriver.Chrome(chrome_options=options, executable_path=executable_path, service_args=["--verbose", f"--log-path={log_path}"])
|
34
134
|
|
35
|
-
driver.get('https://www.google.co.jp')
|
135
|
+
driver.get('https://www.google.co.jp')
|
136
|
+
driver.save_screenshot('screen.png')
|
36
137
|
|
138
|
+
|
139
|
+
if __name__ == "__main__":
|
140
|
+
main()
|
141
|
+
|
142
|
+
|
37
143
|
### 試したこと
|
38
144
|
【pathの登録】
|
39
|
-
C:\
|
145
|
+
C:\selenium\
|
40
146
|
|
41
147
|
【pythonの再インストール、バージョンの変更】
|
42
148
|
python2.xに変更 → 変化なし
|
43
149
|
python3.xを再インストール → 変化なし
|
150
|
+
python3.x 32bit を Anaconda python3.x 64bitに変更 → 変化なし
|
44
151
|
|
45
152
|
【//を/に】
|
46
153
|
『C:\Program Files (x86)\』などの//を
|
@@ -50,9 +157,17 @@
|
|
50
157
|
【同じようなエラーを検索して解決策を実行】
|
51
158
|
https://code.i-harness.com/ja/q/2680e29
|
52
159
|
|
160
|
+
【起動オプションの変更 ※以下に変更】変化なし
|
161
|
+
options.add_argument('--no-sandbox')
|
162
|
+
options.add_argument('--disable-gpu')
|
163
|
+
#options.add_argument('--headless')
|
164
|
+
options.add_argument('--incognito')
|
165
|
+
options.add_argument('--disable-extensions')
|
166
|
+
|
167
|
+
|
53
168
|
### 補足情報(FW/ツールのバージョンなど)
|
54
169
|
【バージョン】
|
55
170
|
windows10 Pro 64bit
|
56
171
|
chrome : 64.0.3282.186(Official Build) (64 ビット)
|
57
|
-
python : 3.6
|
172
|
+
python : 3.6.4 Anaconda [MSC v.1900 64 bit (AMD64)]
|
58
173
|
chromeWebdriver : ChromeDriver 2.35(Supports Chrome v62-64) → chromedriver_win32
|