標題:
怎麼篩選所需要的資料
[打印本頁]
作者:
Jared
時間:
2014-9-11 11:55
標題:
怎麼篩選所需要的資料
想請問一下神人
我目前用,以下兩種寫法不行,主要是想要將『id』、『 stroke』後的引號內資料取出來
LEFT(A1,FIND("=",A1)-1)
MID(A1,SEARCH("""",A1)+1,SEARCH("""",A1,SEARCH("""",A1)+1)-SEARCH("""",A1)-1)
如果想要在資料頁面下 將關鍵字串取出來
函數怎麼寫? 感激不盡><
[attach]19136[/attach]
[attach]19137[/attach]
作者:
GBKEE
時間:
2014-9-12 16:07
回復
1#
Jared
你要抓取的是網頁的資料
Option Explicit
Sub Ex() '抓取ID
Dim URL As String, a As Object, e As Object, i
URL = "http://forum.twbts.com/thread-12514-1-1.html"
'URL = "http://你的網頁"
With CreateObject("InternetExplorer.Application")
.Navigate URL
.Visible = True
Do While .Busy Or .ReadyState <> 4: Loop
Set a = .Document.all
With ThisWorkbook.Sheets(1)
.Cells = ""
On Error Resume Next
For Each e In a
If e.ID <> "" Then
i = i + 1
.Cells(i, "a") = e.TAGNAME
.Cells(i, "B") = e.ID
.Cells(i, "C") = e.innertext '網頁上的文字
End If
Next
End With
.Quit
End With
End Sub
Sub Ex1() '抓取stroke=
Dim SP As Variant, i As Integer
URL = "http://你的網頁"
With CreateObject("Microsoft.XMLHTTP")
.Open "get", URL, False
.send
SP = Split(.responseText, "stroke=""")
End With
With ThisWorkbook.Sheets(2)
.Cells = ""
For i = 1 To UBound(SP)
.Cells(i, "A") = Mid(SP(i), 1, InStr(SP(i), """") - 1)
Next
End With
End Sub
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)