0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
| | Dim uri
uri = Editor.GetSelectedString(0)
If uri = "" Then
uri = "http://www.yahoo.co.jp/"
Else
If Left(uri, 7) <> "http://" And InStr(uri, "/") > 0 Then
Editor.GoFileTop()
Editor.GoLineEnd_Sel(0)
uri = Right(uri, Len(uri) - InStr(uri, "/"))
uri = Editor.GetSelectedString(0) & uri
End If
End If
Editor.SelectAll()
Editor.InsText(uri & " を読み込み中...")
Editor.GoFileTop()
Editor.ReDraw()
Dim ie
Set ie = CreateObject("InternetExplorer.Application")
If Not ie Is Nothing Then
ie.Visible = False
ie.Navigate(uri)
Do While ie.Busy
Loop
Dim body
body = uri & vbCrLf
body = body & ie.document.title & vbCrLf
body = body & "------------------------------------------------------------" & vbCrLf
body = body & get_html(ie.Document.Body.childNodes, "")
Editor.SelectAll()
Editor.InsText(body)
Editor.GoFileTop()
Editor.ReDraw()
ie.Quit()
End If
Function get_html(ByVal document, ByVal margin)
Dim v
For Each v In document
Select Case TypeName(v)
Case "DispHTMLDOMTextNode":
Dim dv, prev_dv
dv = Trim(v.data)
Do
prev_dv = dv
dv = Replace(dv, " ", " ")
Loop While dv <> prev_dv
If dv <> "" Then get_html = get_html & dv
Case "HTMLAnchorElement":
get_html = get_html & get_html(v.childNodes, margin)
get_html = get_html & "<""" & v.href & """>"
Case Else:
Dim indent
indent = ""
Select Case v.tagName
Case "P", "DIV", "TABLE", "TR":
indent = Space(2)
get_html = get_html & vbCrLf & margin
End Select
get_html = get_html & get_html(v.childNodes, margin & indent)
If indent <> "" Then get_html = get_html & vbCrLf
End Select
Next
End Function
|