HTML and Ecxel - Experts help needed

Please post any questions regarding the program here.

Moderator: 2020vision

HTML and Ecxel - Experts help needed

Postby alrodopial » Sun Nov 23, 2008 6:26 pm

Hi, below is the link from the new RP site for the 3.35 race at Towcester (for today).
http://beta.racingpost.com/horses/card_ ... 3&type=sc_

I'm trying to retrieve the whole source page as a text in a cell using the code:
Code: Select all
Sub testing()

    Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
TODAYSmeetingsURL = "http://beta.racingpost.com/horses/card_runners.sd?race_id=468886&race_date=2008-11-23&type=sc_"

ie.navigate TODAYSmeetingsURL
Do While ie.Busy: DoEvents: Loop
    Do While ie.readyState <> 4: DoEvents: Loop
   
    Sheets("temp").Select
    Range("A1").Select

    Set mypage = ie.document.body
    mydata = mypage.innerText
    Sheets("temp").Range("C3") = mydata
   
End Sub


I get some info with the above but not all the source text.If instead of the "innertext" i use the"innerHTML" i get error.
I dont know if i have to convert the innerHTML into text or anything else and how?
Basically i dont understand many things of these stuff, objects,properties,elements,frames ...
So the question is: how can i download the source behind any(?) web page as text in an excel cell?
Anyone?
Garry you know a lot of VBA, any ideas?
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Postby jokerjoe » Sun Nov 23, 2008 7:16 pm

The problem is that an excel cell has a limit on the number of characters in can contain, and the html source code has way more characters than that.

btw I've taken the liberty of cleaning up the code a bit.

Code: Select all
Sub testing()
   
    Dim TODAYSmeetingsURL As String
   
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    TODAYSmeetingsURL = "http://beta.racingpost.com/horses/card_runners.sd?race_id=468886&race_date=2008-11-23&type=sc_"

    ie.navigate TODAYSmeetingsURL
    Do While ie.Busy Or ie.readyState <> 4: DoEvents: Loop
   
    Sheets("Sheet1").Range("C3") = ie.document.body.innertext
   
    ie.Quit
    Set ie = Nothing

End Sub
User avatar
jokerjoe
 
Posts: 122
Joined: Wed May 09, 2007 12:00 pm

Postby alrodopial » Sun Nov 23, 2008 7:31 pm

jokerjoe wrote:The problem is that an excel cell has a limit on the number of characters in can contain, and the html source code has way more characters than that.



So is the syntax OK?
If so is there a way to bypass this limit or some how else?
Splitting the source code?
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Postby dgs2001 » Sun Nov 23, 2008 11:14 pm

Hmmm

I tried this code both ways and all I get each time is two windows open one shows the racing info and the other stays at connecting, and nothing gets to excel.

All help appreciated

Duncan
User avatar
dgs2001
 
Posts: 334
Joined: Thu Apr 05, 2007 4:53 pm
Location: The Home Of National Hunt

Postby alrodopial » Sun Nov 23, 2008 11:50 pm

The code Joe posted works fine at me.
With the "innerHTML" i dont get anything because a cell cant contain so much info so other ways must be found.Dont ask me which.
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm


Return to Help

Who is online

Users browsing this forum: Bing [Bot] and 42 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.