當前位置:編程學習大全網 - 編程軟體 - Excel 求助大神,如何用VBA獲取HTML中<head>裏面的內容

Excel 求助大神,如何用VBA獲取HTML中<head>裏面的內容

<head>之間的內容可以用vba的正則表達式提取。

Function findFiveLetter(sentence)

Dim regEx As New VBScript_RegExp_55.RegExp

Dim matches, s

regEx.Pattern = "<head>.*?</head>"

regEx.IgnoreCase = True 'True to ignore case

regEx.Global = True 'True matches all occurances, False matches the first occurance

s = ""

If regEx.Test(sentence) Then

Set matches = regEx.Execute(sentence)

For Each Match In matches

s = s & " Position: " & Match.FirstIndex

s = s & " Word: " & Match.Value & " "

s = s & Chr(10)

Next

findFiveLetter = s

Else

findFiveLetter = ""

End If

End Function

  • 上一篇:學習到win32的子窗口編程,好難理解啊(主要是不清楚子窗口和主窗口的關系)
  • 下一篇:如何用vb將Access的65438+多萬條數據快速導入EXCEL?知道可以多張存放,怎麽實現?
  • copyright 2024編程學習大全網