VBA Code To Grab Multiple HTML Tables From Web Page

  • Hi Guys


    I obtained some VBA code from a very nice guy on another forum (For some reason I cannot access it at work anymore, but here is the link http://www.excelforum.com/exce…-into-excel-new-post.html)


    The code found my list of hyperlinks on Sheet1 and grabbed the table information from the respective URL and put it on Sheet2, all in line and beautiful. I then wanted to alter this code to suit another website, the Sporting Life, namely the racecards. However, the problems I'm having, being a novice at this, is how to change the code to grab more than just one bit of information.


    Here is an example, which is one of yesterdays races

    http://www.sportinglife.com/racing/racecards/08-10-2012/pontefract/racecard/528423/british-stallion-studs-supporting-british-racing-e-b-f-maiden-stakes


    The code below captures the list from Horse No.1 to Horse No.15, which is good but it is missing the Time "14:40 Pontefract" and the table below this, which is the race Title and Going etc.



    So my question is simply, what needs changing in the code to collect all the tables/information from Race Time to the bottom of the racecard?


    Regards
    Paul

  • Re: VBA Code To Grab Multiple HTML Tables From Web Page


    I'll answer here since MrE seems to be on deaths door.


    The data you are after is not in a table, so specifically which headings are you wanting to return?

  • Re: VBA Code To Grab Multiple HTML Tables From Web Page


    Quote from Kyle123;632142

    I'll answer here since MrE seems to be on deaths door.


    The data you are after is not in a table, so specifically which headings are you wanting to return?


    Ha Ha, I know what you mean, I am really struggling with access to MrE and ExForum, not sure why


    No wonder i was having problems trying to adjust your code, I did nto know..oops ! As per your previous question, I have Ie9 yes. As from your code which was greatly appreciated, I adjusted it to copy the race card, that is the number of horses in the race, from No.1 to whatever it is. However above this is the most important bit which is the race meeting, race time, going, value etc, it is the table (information) directly above the list of horses in the race, does that help?


    Regards
    Paul

  • Re: VBA Code To Grab Multiple HTML Tables From Web Page


    no, not really Again, the data isn't in a table, so you need to be specific. ;) I need a list of everything you want from that page, so far I've got:
    Race Meeting (location) - 14.10 Pontefract
    Race Going - Good to Soft

  • Re: VBA Code To Grab Multiple HTML Tables From Web Page


    Yes, that's the kind of information Kyle. It's all well having the list of horses running but I need the time of race, title etc to go with them :)


    So, you will see the information as thus:


    14:10 Pontefract

    British Stallion Studs Supporting British Racing E.B.F.
    Maiden Stakes


    (2yo, 1m 2f 6y, Class 4, 6 runners)
    Winner £4,399 2nd £1,309 3rd £654 4th £327
    Going: Good to Soft
    Surface: Turf


    If it could import it all then that would be great, followed by the list of horses etc


    Regards
    Paul

  • Re: VBA Code To Grab Multiple HTML Tables From Web Page


    Try this:


    You'll need to add a reference to Microsoft HTML Object Library, I can't get it to late bind properly

  • Re: VBA Code To Grab Multiple HTML Tables From Web Page


    PARFAIT as the French say !!! Well, it worked this time, I'm sure I'll be knocking on your door again if it falls down somewhere <teehee>


    OK..so this is the story


    Part 1>>>>>


    This code gets the Source Code for all Racecards of the day



    Part 2>>>>> I have simple macros that find the racecard information and create the hyperlinks


    Part 3>>>>>


    Kyle's code



    Kyle...thank you :)

  • Re: VBA Code To Grab Multiple HTML Tables From Web Page


    I reckon this will be a little better than part1 and part2


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!