excel get data from web, but with redirecting URL

stevearama

New Member
Joined
Aug 31, 2019
Messages
5
Can anyone help me to use the advanced options on excels DATA > Get Data > From Web menu, to overcome a redirecting URL?
The data I wish to scrape is from this url PAJ Oil Statistics Weekly
However, that URL redirects to here PAJ Oil Statistics Weekly .. which asks me to accept some condition.

Below I have some VBA code that will get me to the correct ULP, it works by first opening IE with the first ULP, then navigating to the second. This works fine, but I wish to implement this inside the Excel GET DATA from Web inteface so that I can scrape the data into excel

Hopefully that question is clear. Thank you for your guidance

VBA Code:
Sub WebLogin()
Dim a As String
    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .navigate "https://stats.paj.gr.jp/en/pub/index.php"
        Do Until .readyState = 4
            DoEvents
        Loop
        .navigate "https://stats.paj.gr.jp/en/pub/current_en_n2.html"
    End With
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
You could do it entirely with VBA; the example below uses the Chrome driver.

VBA Code:
Sub Starama()
Dim driver As New ChromeDriver, pt
driver.get "https://stats.paj.gr.jp/en/pub/index.php"
Set pt = driver.FindElementByXPath("/html/body/div[1]/div/a[1]")
DoEvents
pt.Click
DoEvents
Set pt = driver.FindElementByXPath("//u")
pt.Click
DoEvents
MsgBox "You should see the table page at this point."
Set pt = driver.FindElementByXPath("//div[3]/table[2]/tbody/tr[3]/td/table/tbody")
MsgBox pt.FindElementsByTag("tr").Count, 64, "Number of table rows"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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
Back
Top