extract data from web to inside sheet without open website &refersh

tubrak

Board Regular
Joined
May 30, 2021
Messages
216
Office Version
  1. 2019
Platform
  1. Windows
hi experts
I have this website CMA CGM | A world leader in maritime and logisticsshows me my cargo where is location & when arrive and departure . it depends on CONTAINER NO or B\L NO
let's take CONTAINER NO as the pic 1
1.PNG


and when press shipment tracking it will shows the detials as this picture
2.PNG


so what I want based on last picture show in columns A,B,C,D,E,F= DATE, TIME , MOVES,LOCATION,VESSEL,VOYAGE without open website
and I want put the CONTAINER NO or B\L NO into TEXTBOX1 ACTIVE X and I would press F5 to refresh the search inside the sheet
somtimes doesn't show detiales that's because CONTAINER NO or B\L NO is wrong then should show warning message" please make sure the right detiales "
by the way I use browser google chrome .
thanks
 
Thank you for the feedback
When Edge version changes you'll need to update the driver, as per instructions in post #25.
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
hi
I try to understand your code . I will show another detials. i search the ID and I got this from source webpage
trackingsearchsection
and change this
VBA Code:
Set mElem = WPage.FindElementById("gridTrackingDetails")
to this
VBA Code:
Set mElem = WPage.FindElementById("trackingsearchsection")
but nothing changes
this is what I want showing
nn.PNG

may you see it when you have freetime,please?
 
Upvote 0
So you modified that instruction? And then?
What was you trying to obtain?
 
Upvote 0
the picture
2.PNG


the new based on picture should be
1.PNG


just question if there are some shapes can the code also brings as in end of the picture ?
 
Upvote 0
This version should return what I think you asked for:
VBA Code:
Sub myCaller()
Dim WPage As Object, TBColl As Object
Dim myUrl As String, mElem As Object
Dim I As Long, tbC As Long
'
'Crea Driver:
'    Set WPage = CreateObject("Selenium.EdgeDriver")
    Set WPage = CreateObject("Selenium.CHRomedriver")
'
Sheets("Main").Select
myUrl = Range("B1")
Range("A5").Resize(2000, 30).Clear      'Clear results area
Range("A4").Value = "Returned infos:"
WPage.Get myUrl
WPage.Wait 500
On Error Resume Next
    Set myDoc = WPage.FindElementById("track-number")
    Set myTrack = WPage.FindElementById("searchTracking")
    WPage.FindElementById("onetrust-accept-btn-handler").Click
    WPage.Wait 200
On Error GoTo 0
'
If (Not myDoc Is Nothing) And (Not myTrack Is Nothing) Then
    myDoc.SendKeys Sheets("Main").Range("B2")
    WPage.Wait 100
    myTrack.Click
Else
    MsgBox ("Error A, elements not found")
    GoTo SQuit
End If
WPage.Wait 1000
'ADDED LINES:
Sheets("Main").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = Replace(WPage.FindElementsByClass("resume-filter")(1).Text, Chr(10), " ------ ", , , vbTextCompare)
Sheets("Main").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = Replace(WPage.FindElementsByClass("timeline--progress-description")(1).Text, Chr(10), " ------ ", , , vbTextCompare)
Sheets("Main").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = Replace(WPage.FindElementsByClass("timeline--items")(1).Text, Chr(10), " ------ ", , , vbTextCompare)
Sheets("Main").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = "'="
On Error Resume Next
    Set mElem = WPage.FindElementById("gridTrackingDetails")
    Set TBColl = mElem.FindElementsByTag("table")
    tbC = TBColl.Count
    Debug.Print "TBC= " & tbC
    Debug.Print TypeName(mElem), TypeName(TBColl)
On Error GoTo 0
'
For I = 1 To tbC
    TBColl(I).AsTable.ToExcel Sheets("Main").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Next I

SQuit:
WPage.Quit
Set WPage = Nothing
MsgBox "Completed"
End Sub
There are some "ADDED LINES"

Yes, pictures could be imported, but I am not so good at playing with the pictures
 
Upvote 0
Solution
Yes, pictures could be imported, but I am not so good at playing with the pictures
this is not problem
perfect ! now the project is complete (y)
many thanks for your time :)
 
Upvote 0

Forum statistics

Threads
1,215,208
Messages
6,123,644
Members
449,111
Latest member
ghennedy

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