の特定のオプション値を引くために必要なVBAマクロ:私は現在、Webページをロードするには、次のマクロを持っているWebページ
Sub OOS_Query()
'This together with the True value at the end will tell the macro to not update the screen until it reaches a point that I want it to show updates again
Application.ScreenUpdating = False
ActiveWorkbook.Connections("Connection1").Delete
Sheet2.Range("A:C").Clear
With Sheet2.QueryTables.Add(Connection:= _
"URL;http://[ommitted on purpose]id=42908", Destination:=Sheet2.Range("$A$1"))
.FieldNames = True
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.RefreshPeriod = 5
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "1,2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=True
End With
Application.ScreenUpdating = True
End Sub
あなたはWebページは常にそのように変化している「ID」の値を持って見ることができるようにデータベースに照会します。
Date <select name="id">
<option value='43032' >2017-05-13 05:00:01</option>
<option value='43031' >2017-05-13 04:45:02</option>
<option value='43030' >2017-05-13 04:30:01</option>
<option value='43029' >2017-05-13 04:15:02</option>
私は何idを持つウェブサイトを引っ張ることができるように、コードに統合する方法を探しています
<option value='43004' >2017-05-12 22:00:01</option>
...:Webページのソースに次のようにその値が見えます時間が21:58:00から22:02:00の間である限り、それはあります。現在の日付が何であっても。これが通常行われる方法は、ウェブサイトにアクセスして、ドロップダウンメニューから検索したい日付/時刻を選択し、ウェブサイトを上記のコードのセクションに貼り付けることです。
私はそれを自動的に行うことができれば、コードを毎日編集する必要がなくなります。
ありがとうございます!
22時:01にウェブサイトが表示される時間を選択しない理由は、時々変更されることがあるためです。 – Jahir
DOMまたはXHRから取得したHTMLスニペットですか? – omegastripes
@omegastripesそれはDOMです。 – Jahir