回答編集履歴

2

HTMLDocumentを使わないで直接参照するように変更

2021/06/19 04:04

投稿

neconekocat
neconekocat

スコア443

test CHANGED
@@ -26,13 +26,17 @@
26
26
 
27
27
 
28
28
 
29
- Dim doc As HTMLDocument
29
+ 'Dim doc As HTMLDocument
30
30
 
31
- Set doc = ie.document 'ここにページのデータが入ってる
31
+ 'Set doc = ie.document 'ここにページのデータが入ってる
32
32
 
33
33
 
34
34
 
35
- Debug.Print doc.getElementsByTagName("dd")(21).textContent '検索例
35
+ 'Debug.Print doc.getElementsByTagName("dd")(21).textContent '検索例
36
+
37
+
38
+
39
+ Debug.Print ie.document.getElementsByTagName("dd")(21).textContent '検索例
36
40
 
37
41
  End Sub
38
42
 

1

コードを追記

2021/06/19 04:04

投稿

neconekocat
neconekocat

スコア443

test CHANGED
@@ -2,14 +2,38 @@
2
2
 
3
3
  抽出する方法は検索対象のページのソースとにらめっこしながら考えてください。
4
4
 
5
+ コードを一部追記
6
+
5
7
  ```VBA
6
8
 
7
- Dim doc As HTMLDocument
9
+ Sub OpenURL()
8
10
 
11
+ Dim ie As InternetExplorer
12
+
9
- Set doc = ie.document 'ここにページのデータが入ってる
13
+ Set ie = CreateObject("InternetExplorer.Application")
14
+
15
+ ie.Visible = True
16
+
17
+ ie.Navigate "https://store-tsutaya.tsite.jp/storelocator/detail/2033.html"
10
18
 
11
19
 
12
20
 
21
+ Do While ie.Busy = True Or ie.readyState < READYSTATE_COMPLETE
22
+
23
+ DoEvents
24
+
25
+ Loop
26
+
27
+
28
+
29
+ Dim doc As HTMLDocument
30
+
31
+ Set doc = ie.document 'ここにページのデータが入ってる
32
+
33
+
34
+
13
- Debug.Print doc.getElementsByTagName("dd")(21).textContent '検索例
35
+ Debug.Print doc.getElementsByTagName("dd")(21).textContent '検索例
36
+
37
+ End Sub
14
38
 
15
39
  ```