get data from webpage in excel

auto

Board Regular
Joined
May 20, 2012
Messages
53
hi, everyone;
i am having a code to navigate my IE browser to a webpage, and then from there i want the whole webpage to copy it into my excel sheet. can anyone help me with that?
webquery is not an answer! because i need to do some log-in and other functions till i get to that specific page that i need.
i made already all functions, but i get stuck when it comes to copy the page and paste it into excel, can anyone help me with some coding?
 
everything got messed up here,
i dont know what wrapping i should use for my source page, i tried CODE and it got messed up, what should i use?
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Code:
<table class="data-display" cellspacing="1"><tbody> <tr class="list-row"> <td class="data-display-field" width=30% valign="top"><strong>Shipping Address:</strong><br>john<br>smith<br>1111 Example St.<br>Brooklyn, NY 12090<br></td> <td class="data-display-field" width=50% valign="top"> <table class="data-display" cellspacing="0" cellpadding="0"><tbody> <tr class="list-row"></pre>
 
Last edited by a moderator:
Upvote 0
auto

The source code doesn't really help, plus it's very hard to post it anyway.

If you can post the URL then I can look at the source in context.
 
Upvote 0
its an amazon page, but i cant give the exact url cause its going to my seller account you need to be logged in to get to that page, any solution?
 
Upvote 0
dynamic content doesn't always show up in "html source" anyway. Like Norie said, it's very hard to say without seeing the details - that's what web pages are all about (infinite variety).
 
Upvote 0
auto

What code do you have so far?

You don't need to post anything personal/confidential but if I have something to work with I might be able to demonstrate what I mean.
 
Upvote 0
ok, i will give you the code,
first let me tell you how it works, it opens the webpage taking info from my excel sheet1 and search the page with it, then it will copy the shipping info into my excel on sheet2,
here it is.


Sub GetTheShipping()
Dim I As Long
Dim ie As Object
Dim objElement As Object
Dim objCollection As Object
Dim btnInput As Object ' MSHTML.HTMLInputElement
Dim btntype As Object
Dim btn As Object
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlSheet2 As Excel.Worksheet
Dim oRng As Range
Dim final As Range
Dim bXStarted As Boolean
Const strPath As String = "Test.xlsx"
Const sFilePath As String = "C:\Users\xxx\Desktop\"

On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If Err <> 0 Then
Application.StatusBar = "Please wait while Excel source is opened ... "
Set xlApp = CreateObject("Excel.Application")
bXStarted = True
End If

'Open the workbook
Application.Wait (Now + TimeValue("0:00:02"))

Set xlWB = xlApp.Workbooks.Open(sFilePath & strPath)
Set xlSheet = xlWB.Sheets("Sheet1")
Set xlSheet2 = xlWB.Sheets("Sheet2")
Set oRng = xlSheet.Range("A2")
Set final = xlSheet2.Range("A1")
On Error GoTo 0
'this is the page where to search for that particular info'
web="https://sellercentral.amazon.com/orders/search"
Set ie = CreateObject("InternetExplorer.Application")
' You can uncoment Next line To see form results
ie.Visible = True
' Send the form data To URL As POST binary request
ie.Navigate web
' Statusbar
Application.StatusBar = web & " is loading. Please wait..."
' Wait while IE loading...
Do While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Application.Wait (Now + TimeValue("0:00:04"))


Application.StatusBar = "Search form submission. Please wait..."

Set objCollection = ie.Document.getElementsByTagName("input")


I = 0
While I < objCollection.Length
If objCollection(I).Name = "searchKeyword" Then
' Set text for search
objCollection(I).Value = oRng
End If
I = I + 1
Wend

Set btn = ie.Document.getElementsByTagName("button")

I = 0

While I < btn.Length
If btn(I).Name = "Search" Then
Set objElement = btn(I)
objElement.Click ' click button to search
End If
I = I + 1
Wend

' Wait while IE re-loading...
Do While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Loop

Application.Wait (Now + TimeValue("0:00:04"))


ie.ExecWB 17, 0
ie.ExecWB 12, 0
final.PasteSpecial xlPasteValues







' Clean up
Set ie = Nothing
Set objElement = Nothing
Set objCollection = Nothing

Application.StatusBar = ""

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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