Cannot pull table from different tabs within the same webpage.

mj sachoo

New Member
Joined
Nov 18, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to obtain the data table from website. However, I can only extract the data from the 'Price' tab.

1605753640023.png


I cannot obtain the tables under the 'Performance', 'Technical and 'Fundamental Tabs.

I get the following error when trying to click the other tabs:

1605753837311.png


I do not know how to get these tables from other tabs.

Last hope is this website as I have not got anything from other forums or websites.

Please advise.

Thanks
 
Yes I want to be able to select them manually because the macro won't be able to scrape the right data. i think it's the way the website is is.
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
1655310586286.png


that's the error I am getting after I changed the "chrome" to "edge", though the edge could load the page now.

please, I want to be able to select the table I want manually select the table myself and with two callers that won't load automatically. the data that is being retrieved are not the right data. if you can recall the reason I tried making use of this method was because data query couldn't see the rest of the table that are included in the same webpage but different tab.

Please I would like it , if you can help me to modify the code in thread 14 that works perfectly earlier with Internet Explorer and configure it to work with Edge. but the website should be change to " Tables, Virtual Football League Mode 26378, Virtual Football, Soccer" thanks.
 
Upvote 0
That is the demofile that exploit the published macro

It imports 5 + 5 tables

As I said, I had to use the deprecated Sendkeys funcion to enable the "inspector tool"; this require that you don't interact with the pc after the macro has been started (it should take a few seconds)
That message arise when the inspector tool don't get open.
In my Edge or Chrome, the inspector get open by pressing Contr-Shift-i
So open your browser and type Contr-Shift-i and check that the inspector tool opens (this is a frame normally on the right of the browser windows that shows internal information of the page); if the tool don't open then google to get the right sequence for your browser version and we will change the SendKeys command
 
Upvote 0
I got the chrome web driver updated, so it has collect the data, but the image I attached still coming up, then I pressed "debug" it highlighted "WPage.FindElementById(tabList(Cycle)).Click" then it collect the data afterward.


Please, I want to be able to get the data manually by using "stop the way you did in thread 14. pls kindly help to modify the thread 14 to use chrome instead of explorer . the thread 14 code brings what I want and it manual, I can select it myself. but loading automatically brings wrong data, I attached the thread 14 code, maybe you will be able to modify it to use Chrome instead of Internet Explorer.

I'm sorry for any inconveniences I may have cause for you.


help me to make the attached code work with chrome. thanks

Thank You.

VBA Code:
Sub Call1()
    Sheets("AAA").Select       '<<< The sheet that will be loaded
    Cells.ClearContents            'NB: that sheet will be cleared!!
    Call GetTabbbSub("https://s5.sir.sportradar.com/bet9javirtuals/en/1/season/2382095/standings")     '<<< Your starting Url
    Cells.WrapText = False
End Sub

Sub Call2()
    Sheets("BBB").Select       '<<< The sheet that will be loaded
    Cells.ClearContents            'NB: that sheet will be cleared!!
    Call GetTabbbSub("https://s5.sir.sportradar.com/bet9javirtuals/en/1/season/2382095/standings")     '<<< Your starting Url
    Cells.WrapText = False
End Sub

Sub GetTabbbSub(ByVal myURL As String)
'See http://www.pc-facile.com/forum/viewtopic.php?f=26&t=105843#p619587
Set IE = CreateObject("InternetExplorer.Application")
  
With IE
    .navigate myURL
    .Visible = True
Stop                '*** VEDI Testo
    Do While .Busy: DoEvents: Loop    'Attesa not busy
    Do While .readyState <> 4: DoEvents: Loop 'Attesa documento
End With
'
myStart = Timer  'attesa addizionale
Do
    DoEvents
    If Timer > myStart + 1 Or Timer < myStart Then Exit Do
Loop

'Write table values on the active sheet:
Set myColl = IE.document.getElementsByTagName("TABLE")
For Each myItm In myColl
    Cells(I + 1, 1) = "Table# " & ti + 1
    ti = ti + 1: I = I + 1
    For Each trtr In myItm.Rows
        For Each tdtd In trtr.Cells
            Cells(I + 1, j + 1) = tdtd.innerText
            j = j + 1
        Next tdtd
        I = I + 1: j = 0
DoEvents
    Next trtr

I = I + 1
Next myItm
'
'Chiusura IE
IE.Quit
Set IE = Nothing
End Sub
 
Upvote 0
Please, I want to be able to get the data manually by using "stop the way you did in thread 14. pls kindly help to modify the thread 14 to use chrome instead of explorer . the thread 14 code brings what I want and it manual, I can select it myself. but loading automatically brings wrong data, I attached the thread 14 code, maybe you will be able to modify it to use Chrome instead of Internet Explorer.
Use tha macro provided in post #22, adding a Stop to set manually the option and removing the worksheet selection (so it will work on the Active sheet):
VBA Code:
Sub SeleniumSportradarManual()
Dim TbColl As Object, tArr, myItm As Object
Dim I As Long, J As Long, myTim As Single
Dim WPage As Object
Dim myUrl As String
'
'CONFIGURATION:
myUrl = "https://s5.sir.sportradar.com/bet9javirtuals/en/1/season/2403775/standings"     '<<< The web page
''Sheets("Tables").Select                     '<<< The sheet to use    REMOVED, WILL WORK WITH THE ACTIVESHEET
Range("A:T").ClearContents                  '<<< Clear the sheet?
'
myTim = Timer
Set WPage = CreateObject("Selenium.WebDriver")
WPage.Start "Chrome", myUrl                         ' <11
''WPage.Start "edge", myUrl                          ' <22
WPage.Get "/"
'
On Error Resume Next
J = 0
J = Range("A:T").Find(What:="*", After:=Range("A1"), _
              SearchOrder:=xlByRows, _
              SearchDirection:=xlPrevious).Row
On Error GoTo 0
J = J + 2

Stop                                                                          '<<< SELECT THE TAB YOU WISH, THEN "CONTINUE" THE MACRO

Debug.Print vbCrLf & "Start", "J= " & J, WPage.Url, Format(Timer - myTim, "0.00")
Set TbColl = WPage.FindElementsByTag("table")
Debug.Print "Tables found: " & TbColl.Count, Format(Timer - myTim, "0.00")
For I = 1 To TbColl.Count
    Cells(J, 2).Value = "Table #" & I
    tArr = TbColl(I).AsTable.Data
    Cells(J + 1, 1).Resize(UBound(tArr), UBound(tArr, 2)).Value = tArr
    Debug.Print "Table #" & I, UBound(tArr) & " * " & UBound(tArr, 2)
    J = J + UBound(tArr) + 3
Next I
'
Debug.Print "END", I, J, Format(Timer - myTim, "0.00")
WPage.Quit
MsgBox ("Collected...")
End Sub

When the macro stops, press in the browser the preferred tab; then "continue" the macro using F5
 
Upvote 0
It works, thank you so much, but what is left now is for me to be able to create caller for it, so I could load Home table in sheet 1 and away table in sheet 2.

thanks so much
 
Upvote 0
it work for both. thank you so much

I appreciate your help Anthony
 
Upvote 0
Hello @Anthony47
How have you been?
Pls I will need your help one more time. I haven't been able to use the former VBA code effectively because, the game I wanted to use it to analyze is a virtual sport which I have less than a minute to load two different tables (Home and Away) from the web and I still have to analyze it.

I'm thinking of another option if it can be successful it will solve the time wastage.

Pls can you help me to write a code that will pull the table from this link

Fixtures, Virtual Football League Mode 27688, Virtual Football, Soccer

I want everything on the page to be pull out in text format (not number or general)

I want the data pull automatic (not stop, that I will have to navigate the table I want)

The web page can not display all the content at once, you have to click on "see more" to display more. I want the code to pull all the content at once instead. (i.e. from roll 1 to the last roll)

I don't really know how you are going to go about it, if it will require salenium like the previous one. in case it will require it, pls kindly remember to use Chrome

below is the attached screenshot of how the webpage looks like.

I hope for your kind consideration.

Thank You.


1664118824231.png
 
Upvote 0
Try the following maceo:
VBA Code:
Sub Sportrdr()
Dim TbColl As Object, myTab, BColl As Object, pCount As Long
Dim I As Long, J As Long, mySplit, myTim As Single
Dim WPage As New WebDriver
'
Sheets("Foglio3").Select            '<<< The sheet for the results
'
WPage.Start "Chrome", "https://s5.sir.sportradar.com/bet9javirtuals/en/1/season/2477086/fixtures/full"
WPage.Get "/"
'
myTim = Timer
Range("A:E").ClearContents
Range("C:D").NumberFormat = "@"
'
Do
    WPage.Wait 700
    Set BColl = WPage.FindElementsByTag("Button")
    If BColl.Count > 0 And BColl(BColl.Count).Text = "Show more" Then
        BColl(BColl.Count).Click
        WPage.Wait 200
    Else
        Exit Do
    End If
Loop
Set TbColl = WPage.FindElementsByTag("table")
myTab = TbColl(1).AsTable.Data
For I = 1 To UBound(myTab)
    myTab(I, 3) = Left(myTab(I, 3), Len(myTab(I, 3)) / 2)
    myTab(I, 4) = Left(myTab(I, 4), Len(myTab(I, 4)) / 2)
Next I
Range("A1").Resize(UBound(myTab), UBound(myTab, 2)).Value = myTab
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,119
Messages
6,128,947
Members
449,480
Latest member
yesitisasport

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