Web query multiple pages

ranmantx

New Member
Joined
Dec 11, 2009
Messages
6
I am seeking help with writing a web query that pulls info from a website that spans multiple pages. I can provide actual url via private message if required. I just prefer not to post it in public forum.

  • Logs into website using name/password
  • Site then redirects to page 1 with tables
  • tables span across multiple webpages - end of url is sequential xyz.com/page=1 , xyz.com/page=2 , etc.
  • Ending page number varies (need method to input that before each query)
  • Has header at top of each table (bonus if could exclude downloading this)
Sub URL_Get_Query()
Dim MyPost As String
Const MyUrl As String = "http://xyz.com/account/login"
Const PostUser As String = "handle=xyz"
Const PostPassword As String = "&password=xyz123"
MyPost = PostUser & PostPassword

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & MyUrl, Destination:=Cells(1, 1))
.PostText = MyPost
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://xyz.com/admin/earnings/current?page=1?", _
Destination:=Range("a1"))

.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://xyz.com/admin/earnings/current?page=2", _
Destination:=Range("a17"))

.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With
End Sub
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Watch MrExcel Video

Forum statistics

Threads
1,122,521
Messages
5,596,650
Members
414,083
Latest member
Mrsash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top