回答編集履歴

3

fix

2017/07/07 02:35

投稿

mattn
mattn

スコア5030

test CHANGED
@@ -1,3 +1,19 @@
1
+ 一括で取りたい場合
2
+
3
+
4
+
5
+ ```vbs
6
+
7
+ Set doc = IE.Document
8
+
9
+ Set names = doc.getElementsByClassName("Name")
10
+
11
+ WScript.Echo names(0).TextContent
12
+
13
+ ```
14
+
15
+
16
+
1
17
  ```vbs
2
18
 
3
19
  Set doc = IE.Document

2

fix

2017/07/07 02:35

投稿

mattn
mattn

スコア5030

test CHANGED
@@ -1,38 +1,4 @@
1
1
  ```vbs
2
-
3
- Set doc = IE.Document
4
-
5
- Set names = doc.getElementsByClassName("Name")
6
-
7
- WScript.Echo names(0).TextContent
8
-
9
- ```
10
-
11
-
12
-
13
- テキストだけで良いなら TextContent で取れると思います。個別に取りたい場合は以下。
14
-
15
-
16
-
17
- ```vbs
18
-
19
- Set IE = CreateObject("InternetExplorer.Application")
20
-
21
-
22
-
23
- IE.Visible = True
24
-
25
- IE.Navigate "http://127.0.0.1:5000/"
26
-
27
-
28
-
29
- Do While IE.Busy Or IE.ReadyState <> 4
30
-
31
- WScript.Sleep(1)
32
-
33
- Loop
34
-
35
-
36
2
 
37
3
  Set doc = IE.Document
38
4
 

1

fix

2017/07/07 02:34

投稿

mattn
mattn

スコア5030

test CHANGED
@@ -10,4 +10,46 @@
10
10
 
11
11
 
12
12
 
13
- テキストだけで良いなら TextContent で取れると思います。
13
+ テキストだけで良いなら TextContent で取れると思います。個別に取りたい場合は以下。
14
+
15
+
16
+
17
+ ```vbs
18
+
19
+ Set IE = CreateObject("InternetExplorer.Application")
20
+
21
+
22
+
23
+ IE.Visible = True
24
+
25
+ IE.Navigate "http://127.0.0.1:5000/"
26
+
27
+
28
+
29
+ Do While IE.Busy Or IE.ReadyState <> 4
30
+
31
+ WScript.Sleep(1)
32
+
33
+ Loop
34
+
35
+
36
+
37
+ Set doc = IE.Document
38
+
39
+ Set names = doc.getElementsByClassName("Name")
40
+
41
+ For Each a In names(0).Children(0).Children
42
+
43
+ If a.NodeName = "P" Then
44
+
45
+ WScript.Echo a.TextContent
46
+
47
+ End If
48
+
49
+ Next
50
+
51
+ ```
52
+
53
+
54
+
55
+ `.Document.getElementsByName` で取れますが、HTML 構造によっては期待した通りに取れないのであえて Children 使っています。