I successfully made my own macro which scraped infomation from
URLs http://www.sda.gov.cn/WS01/CL0027/index_1.html...index_2.html...index_3.html etc.
using these code
but I'm facing a little problem, actually the items in these URLs are added in a daily basis and the most recent info will be stored in![]()
Sub Macro1() Dim i As Integer For i = 1 To 83 ' ' Macro1 Macro ' ' With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://www.sda.gov.cn/WS01/CL0027/index_" & i & ".html", Destination:=Range("$A$1" _ )) .Name = "index" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = False .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlSpecifiedTables .WebFormatting = xlWebFormattingAll .WebTables = "22" .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With Next i End Sub
http://www.sda.gov.cn/WS01/CL0027/index.html while the outdated one will be moved to the subsequent pages i.e. index_1, index_2....
Thus, my questions are
- How can i included the first page http://www.sda.gov.cn/WS01/CL0027/index.html in my macro loop?
- Is it able to add a checking against the total number of pages so that the macro wont miss any newly added page?
I m just new to the macro stuff, any help would be appreciated!
Thanks in advance!
Sam.
Bookmarks