website information using ie

SQUIDD

Well-known Member
Joined
Jan 2, 2009
Messages
2,126
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Good morning all

Im a bit stuck trying to get information from a pasricular website.

please see below a page from the website.

http://greyhoundbet.racingpost.com/...910&track_id=7&r_date=2010-03-12&r_time=11:03

My problem is im trying to obtain the traps numbers

so in the example page

1st position was trap 6
2nd position was trap 3
and so on

i can see the wording in the 1st container as "big trap 6", but cannot seem to extract that. If i can get that wording out for each of the 6 containers im good, but im lost on this one.

any help will be hugly appriciated.
code below that grabs the 1st position and puts out a message box

Code:
Sub getinfo()
Set ie = CreateObject("InternetExplorer.Application")
With ie
link = "http://greyhoundbet.racingpost.com/#result-meeting-result/race_id=1015910&track_id=7&r_date=2010-03-12&r_time=11:03"
        ie.navigate link
        ie.Visible = True
        Do While ie.Busy: DoEvents: Loop
        Do Until ie.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    End With
    Application.Wait (Now + TimeValue("00:00:03"))
    Set doc = ie.document
    MsgBox (doc.getElementsByClassName("place")(0).innerText)
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
OK

SO I SUSSED OUT ABOVE

doc.getElementsByClassName("bigTrap")(0).className

Now im wondering how i can get the href from a class name?

any takers, thanks

dave
 
Upvote 0
Have you viewed with Firefox. Inspect Element from the right click menu
 
Upvote 0
Hi Mole

Thanks for the reply, yes i have.

But i cannot seem to extract just the href from a particular class.

sorry if this sounds like i know nothing, but its tru.

ok,

so the line reads

a class="details highlight highlightFade" href= "#results-dog/race_id=1015910&dog_id=328980&r_date=2010-03-12&track_id=7&r_time=11:03"

i just not sure how to go about extracting that particular href text?

thanks

dave
 
Upvote 0
I have done it with a work around

Code:
Set link = doc.getElementsByTagName("a")
            For Each p In link
                If p.href Like ("*dog/race*") Then Range("'RACE'!D" & counter + 1) = p.href
            Next p

with a loop to check contents of the href

Just does not seem so efficient

but happy i got it working

thanks

Dave
 
Upvote 0
sorry, it way out of my knowledge
 
Upvote 0
Hi Mole

It all working now, so thanks anyway.

Dave
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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