给定一个网址,如何在Excel中获取VBA中html页面的标题?
例如假设我有三个网址:
现在我需要在另一列中获取这些html页面的标题。我该怎么做?
答案 0 :(得分:6)
所以只需添加
wb.Quit
一切都会好的。
这是适用于我的代码:
Function GetTitleFromURL(sURL As String)
Dim wb As Object
Dim doc As Object
Set wb = CreateObject("InternetExplorer.Application")
wb.Navigate sURL
While wb.Busy
DoEvents
Wend
GetTitleFromURL = wb.Document.Title
wb.Quit
Set wb = Nothing
End Function
答案 1 :(得分:5)
我不确定你的名字是什么意思,但这是一个想法:
Dim wb As Object
Dim doc As Object
Dim sURL As String
Set wb = CreateObject("InternetExplorer.Application")
sURL = "http://lessthandot.com"
wb.Navigate sURL
While wb.Busy
DoEvents
Wend
''HTML Document
Set doc = wb.document
''Title
Debug.Print doc.Title
Set wb = Nothing
答案 2 :(得分:0)
如果你使用硒:
Sub Get_Title()
Dim driver As New WebDriver
debug.print driver.Title
End Sub