質問編集履歴

2

python

2018/08/17 06:13

投稿

hikaa
hikaa

スコア19

test CHANGED
File without changes
test CHANGED
@@ -1,117 +1,115 @@
1
+ 以下のように株価のスクレイピングを行おうとしていますが、ウインドウの切り替えがうまくいきません。なぜでしょうか?ウインドウのデータは習得できているはずなのですが・・・。
2
+
3
+
4
+
5
+ よろしくお願いします。
6
+
7
+
8
+
9
+
10
+
11
+ ### **以下エラーコード**
12
+
13
+  oSuchWindowException Traceback (most recent call last)
14
+
15
+ <ipython-input-131-fafd9a338816> in <module>()
16
+
17
+ ----> 1 sikomi1(numbers)
18
+
19
+
20
+
21
+ <ipython-input-129-96a41ed9cde1> in sikomi1(numbers)
22
+
23
+ 29 while num <len(numbers): #ブラウザ更新して、初値が付いたら
24
+
25
+ 30 print(wh[num])
26
+
27
+ ---> 31 wd.switch_to_window(wh[num])
28
+
29
+ 32 wd.refresh()
30
+
31
+ 33 sine[num] = wd.find_element_by_xpath("//div[@id='detail']/div[2]/div[2]/dl/dd/strong").text
32
+
33
+
34
+
35
+ ~\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py in switch_to_window(self, window_name)
36
+
37
+ 777 """
38
+
39
+ 778 warnings.warn("use driver.switch_to.window instead", DeprecationWarning)
40
+
41
+ --> 779 self._switch_to.window(window_name)
42
+
43
+ 780
44
+
45
+ 781 def switch_to_frame(self, frame_reference):
46
+
47
+
48
+
49
+ ~\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\switch_to.py in window(self, window_name)
50
+
51
+ 113 return
52
+
53
+ 114 data = {'name': window_name}
54
+
55
+ --> 115 self._driver.execute(Command.SWITCH_TO_WINDOW, data)
56
+
57
+ 116
58
+
59
+ 117 def _w3c_window(self, window_name):
60
+
61
+
62
+
63
+ ~\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
64
+
65
+ 318 response = self.command_executor.execute(driver_command, params)
66
+
67
+ 319 if response:
68
+
69
+ --> 320 self.error_handler.check_response(response)
70
+
71
+ 321 response['value'] = self._unwrap_value(
72
+
73
+ 322 response.get('value', None))
74
+
75
+
76
+
77
+ ~\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
78
+
79
+ 240 alert_text = value['alert'].get('text')
80
+
81
+ 241 raise exception_class(message, screen, stacktrace, alert_text)
82
+
83
+ --> 242 raise exception_class(message, screen, stacktrace)
84
+
85
+ 243
86
+
87
+ 244 def _value_or_default(self, obj, key, default):
88
+
89
+
90
+
91
+ NoSuchWindowException: Message: no such window
92
+
93
+ (Session info: chrome=68.0.3440.106)
94
+
95
+ (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.17134 x86_64)
96
+
97
+
98
+
99
+ Message: no such window
100
+
101
+
102
+
103
+ と出てしまいます。
104
+
105
+
106
+
107
+
108
+
109
+ ### __**以下ソースコード**__
110
+
1
111
  ```python
2
112
 
3
- コード
4
-
5
- ```以下のように株価のスクレイピングを行おうとしていますが、ウインドウの切り替えがうまくいきません。なぜでしょうか?ウインドウのデータは習得できているはずなのですが・・・。
6
-
7
-
8
-
9
- よろしくお願いします。
10
-
11
-
12
-
13
-
14
-
15
- ### **以下エラーコード**
16
-
17
-  oSuchWindowException Traceback (most recent call last)
18
-
19
- <ipython-input-131-fafd9a338816> in <module>()
20
-
21
- ----> 1 sikomi1(numbers)
22
-
23
-
24
-
25
- <ipython-input-129-96a41ed9cde1> in sikomi1(numbers)
26
-
27
- 29 while num <len(numbers): #ブラウザ更新して、初値が付いたら
28
-
29
- 30 print(wh[num])
30
-
31
- ---> 31 wd.switch_to_window(wh[num])
32
-
33
- 32 wd.refresh()
34
-
35
- 33 sine[num] = wd.find_element_by_xpath("//div[@id='detail']/div[2]/div[2]/dl/dd/strong").text
36
-
37
-
38
-
39
- ~\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py in switch_to_window(self, window_name)
40
-
41
- 777 """
42
-
43
- 778 warnings.warn("use driver.switch_to.window instead", DeprecationWarning)
44
-
45
- --> 779 self._switch_to.window(window_name)
46
-
47
- 780
48
-
49
- 781 def switch_to_frame(self, frame_reference):
50
-
51
-
52
-
53
- ~\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\switch_to.py in window(self, window_name)
54
-
55
- 113 return
56
-
57
- 114 data = {'name': window_name}
58
-
59
- --> 115 self._driver.execute(Command.SWITCH_TO_WINDOW, data)
60
-
61
- 116
62
-
63
- 117 def _w3c_window(self, window_name):
64
-
65
-
66
-
67
- ~\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
68
-
69
- 318 response = self.command_executor.execute(driver_command, params)
70
-
71
- 319 if response:
72
-
73
- --> 320 self.error_handler.check_response(response)
74
-
75
- 321 response['value'] = self._unwrap_value(
76
-
77
- 322 response.get('value', None))
78
-
79
-
80
-
81
- ~\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
82
-
83
- 240 alert_text = value['alert'].get('text')
84
-
85
- 241 raise exception_class(message, screen, stacktrace, alert_text)
86
-
87
- --> 242 raise exception_class(message, screen, stacktrace)
88
-
89
- 243
90
-
91
- 244 def _value_or_default(self, obj, key, default):
92
-
93
-
94
-
95
- NoSuchWindowException: Message: no such window
96
-
97
- (Session info: chrome=68.0.3440.106)
98
-
99
- (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.17134 x86_64)
100
-
101
-
102
-
103
- Message: no such window
104
-
105
-
106
-
107
- と出てしまいます。
108
-
109
-
110
-
111
-
112
-
113
- ### __**以下ソースコード**__
114
-
115
113
  def sikomi1(numbers):
116
114
 
117
115
  wh = [] #ウインドウ番号
@@ -204,6 +202,8 @@
204
202
 
205
203
 
206
204
 
205
+ ```
206
+
207
207
  ### **実行結果**
208
208
 
209
209
  ['CDwindow-8A8D9A9BE0F1B07B14027E7A1468EA5C', 'CDwindow-9D725EAE0F62DBD1390ACC33DB00C3D2']

1

pytho

2018/08/17 06:13

投稿

hikaa
hikaa

スコア19

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,8 @@
1
+ ```python
2
+
3
+ コード
4
+
1
- 以下のように株価のスクレイピングを行おうとしていますが、ウインドウの切り替えがうまくいきません。なぜでしょうか?ウインドウのデータは習得できているはずなのですが・・・。
5
+ ```以下のように株価のスクレイピングを行おうとしていますが、ウインドウの切り替えがうまくいきません。なぜでしょうか?ウインドウのデータは習得できているはずなのですが・・・。
2
6
 
3
7
 
4
8