2017-01-08 85 views
1
<tbody> 
      <tr> 
       <td> 
        <a href="/denmark/1st-division/">1st Division 2016/2017</a> 
       </td> 
        <td> 
        </td> 
      </tr> 
      <tr class="even"> 
       <td> 
        <a href="/denmark/1st-division-2015-2016/">Bet25 Liga 2015/2016</a> 
       </td> 
        <td> 

嗨,大家好!我想得到這個:Bet25 Liga 2015/2016從源代碼。如何從特定的類中獲取特定的InnerText?

Sub ExtractHrefClass() 

    With CreateObject("MSXML2.XMLHTTP") 
     .Open "GET", Range("D8").Value, False 
     .Send 
     Range("E8").Value = Split(Split(Split(.ResponseText, "<tr class=""even"">", 2)(1), "<a href=""", 2)(1), """", 2)(0) 
    End With 

End Sub 

一個朋友給我這個宏,讓我來提取「甚至」類的HREF,但我需要有的innerText了。我必須更改代碼?謝謝:)

+0

請分享'D8'細胞的URL。 – omegastripes

+0

@omegastripes http://www.soccer24.com/denmark/1st-division/archive/,今天我給你發一封郵件給我的朋友^^ – ALIENATO

+0

@omegastripes對不起,但我需要更多的東西,當宏運行錯誤* *(下標超出範圍)**因爲它沒有找到它正在尋找的東西,我想繼續下一個宏 – ALIENATO

回答

2

試試下面的代碼:

Sub ExtractHrefClass() 

    With CreateObject("MSXML2.XMLHTTP") 
     .Open "GET", Range("D8").Value, False 
     .Send 
     a = Split(Split(Split(.ResponseText, "<tr class=""even"">", 2)(1), "<a href=""", 2)(1), """>", 2) 
    End With 
    Range("E8").Value = a(0) 
    Range("F8").Value = Split(a(1), "<", 2)(0) 

End Sub 
+0

哇我的朋友,它的工作很棒! :D – ALIENATO

+0

@ALIENATO你能否分享給出'下標超出範圍'錯誤的URL? – omegastripes

+0

這是[鏈接](http://www.soccer24.com/denmark/1st-division/) – ALIENATO