Scrape from webpages without table and classes

Bruzio

Board Regular
Joined
Aug 20, 2020
Messages
85
Office Version
  1. 2016
Platform
  1. Windows
  2. Mobile
Hi to everyone, surfing I found this website BsportsFan It has some interesting data.
The landing pages haven't tables or classes so I wasn't able to get that data. A few months ago @smozgur who I greet, made a vba code for me, I'm still using that sheet, maybe also using this website.
Inspecting the site I found this info:


home.jpg


The destination url is https://app.bsportsfan.com/events/inplay, by clicking on an event i found:

odds.jpg


The destination url is https://app.bsportsfan.com/event/odds?id=3225440.
By changing the id I can find all the data for each event.

My goal is to have this data in a sheet.
I would like to know what tools I need to use.
I apologize if mine are trivial requests.

Thank you for your attention and have a nice day
 
The delimiters are different too, comma or dash or slash.
When there's the delimiter I would need to have the average of the two values, I tried with Average(Split.... with no success.

VBA Code:
oddsTypes = Split("home_od,draw_od,away_od,home_od,handicap,away_od,over_od,handicap,under_od", ",")
Is this the string to edit?

No, oddsTypes is the list of JSON field names for the different types of odds which are extracted.

Try something like this to calculate the average when there are 2 values. I've done it for the comma and slash separators. I don't know about the dash separator - how would you distinguish it from "-" for negative values?

Replace:
VBA Code:
                                        If Not IsEmpty(odds(company)(times(i))(divs(j))) Then
                                            .Cells(r, c + i * 9 + j * 3 + k).Value = odds(company)(times(i))(divs(j))(oddsTypes(k + j * 3))
                                        End If
with:
VBA Code:
                                        If Not IsEmpty(odds(company)(times(i))(divs(j))) Then
                                            Dim oddsString As String, parts As Variant
                                            oddsString = odds(company)(times(i))(divs(j))(oddsTypes(k + j * 3))
                                            parts = Split(oddsString, ",")
                                            If UBound(parts) = 0 Then parts = Split(oddsString, "/")
                                            If UBound(parts) = 0 Then
                                                .Cells(r, c + i * 9 + j * 3 + k).Value = oddsString
                                            Else
                                                .Cells(r, c + i * 9 + j * 3 + k).Value = (CSng(parts(0)) + CSng(parts(1))) / 2  'average
                                            End If
                                        End If
                                    End If
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I don't know about the dash separator - how would you distinguish it from "-" for negative values?
Yes, I think isn't possible to distinguish, no problem for this.

The code works but the average not, for example:

+2/2.5 = 2.25 instead it returns 13,5 :unsure:

Qatar U23 LeagueAl Khor U23Al Gharafa U230-01112,507,401,111,9813,51,861,823,52,00
 
Upvote 0
I can't reproduce. +2/2.5 calculates as 2.25 for me. Time to do some debugging for yourself.

I use this to put the raw odds and calculated value in the cell:

VBA Code:
                                                .Cells(r, c + i * 9 + j * 3 + k).Value = oddsString & " = " & (CSng(parts(0)) + CSng(parts(1))) / 2 'average
 
Upvote 0
Hi, I'm trying right now

Nepal B DivisionRanipokhari Corner TeamNaya Basti Yuwa Club2-2723,13,421,9750.0,+0.5 = 2,5

id 3277454
company Bet365

Maybe there are problems with decimals because it should be 0.25

Australia W-LeagueWestern Sydney Wanderers WomenMelbourne City Women03,54,21,6661,825+0.5,+1.0 = 7,5
Here it should be 0,75

I tried with

VBA Code:
.Cells(r, c + i * 9 + j * 3 + K).Value = oddsString & " = " & ((CSng(parts(0)) + CSng(parts(1))) / 2) / 10

It works but is an illogical calculation

Nepal B DivisionRanipokhari Corner TeamNaya Basti Yuwa Club2-2833,13,421,9750.0,+0.5 = 0,251,825
Australia W-LeagueWestern Sydney Wanderers WomenMelbourne City Women0-0103,54,21,6661,825+0.5,+1.0 = 0,751,975
 
Last edited:
Upvote 0
VBA Code:
.Cells(r, c + i * 9 + j * 3 + K).Value = oddsString & " = " & ((CSng(parts(0)) + CSng(parts(1))) / 20)

It works too

Australia W-LeagueWestern Sydney Wanderers WomenMelbourne City Women0-0183,54,21,6661,825+0.5,+1.0 = 0,751,975

Here with 188Bet so with "/"

Australia W-LeagueWestern Sydney Wanderers WomenMelbourne City Women0-0203,453,751,771,85+0.5/1 = 0,31,99
 
Last edited:
Upvote 0
Hi @John_w, for a other method I'm using

VBA Code:
For r = 4 To 10  '.Cells(.Rows.Count, "A").End(xlUp).Row  'test on id rows 4-10
      
            id = .Cells(r, "A").Value
The IDs come from formulas and I have this result:

1996563Israel Liga Bet NorthTzeirei Kfar KannaHapoel Ironi Karmiel1016
1996453International MatchUnited Arab EmiratesIndia20451.394.007.402.021.251.901.902.252.00
1996448U21 InternationalUkraine U21Slovakia U2100462.383.052.671.8102.031.842.51.98
1996447U21 InternationalNorth Macedonia U21Bulgaria U2121553.053.252.082.04-0.251.801.892.751.93
3.053.252.082.04-0.251.801.892.751.93
3.053.252.082.04-0.251.801.892.751.93
3.053.252.082.04-0.251.801.892.751.93
3.053.252.082.04-0.251.801.892.751.93
3.053.252.082.04-0.251.801.892.751.93
3.053.252.082.04-0.251.801.892.751.93
3.053.252.082.04-0.251.801.892.751.93
3.053.252.082.04-0.251.801.892.751.93
3.053.252.082.04-0.251.801.892.751.93
3.053.252.082.04-0.251.801.892.751.93

How can I fix it?

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

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