dadamssg Posted August 20, 2010 Share Posted August 20, 2010 I'm trying to create a mac widget that will display my college's football schedule. How do i get started pulling the table data of this page? or any webpage for that matter? It doesn't appear to wrapped in any kind of xml http://www.aggieathletics.com/sports/m-footbl/sched/tam-m-footbl-sched.html The html is about 3/4 of the down in the source code. Quote Link to comment Share on other sites More sharing options...
dadamssg Posted August 20, 2010 Author Share Posted August 20, 2010 I'm trying to create a widget to display different college football schedules. I know the simple html dom plug in will do the trick, i just don't know how to find dom objects. I want to grab a table with the id of "schedtable" and display its contents. Any advice or help would be much appreciated! this is what i got so far...not much haha <?php include("simple_html_dom.php"); // Create DOM from URL or file $html = file_get_html('http://www.aggieathletics.com/sports/m-footbl/sched/tam-m-footbl-sched.html'); //code to display the schedule table???? ?> Quote Link to comment Share on other sites More sharing options...
oliverj777 Posted August 20, 2010 Share Posted August 20, 2010 Well, the thing is, is that you need to retrieve the table ID (or whatever form of ID it is using) from the website. From there, you can get PHP to connect to the HTTP and find the particular table ID with a _GET and then simply do an echo Quote Link to comment Share on other sites More sharing options...
dadamssg Posted August 21, 2010 Author Share Posted August 21, 2010 could you should me or point me in a direction as to where i can learn how to do that? this is the tutorial im going off of but it doesn't work with another site. // Create DOM from string $html = str_get_html('<div id="hello">Hello</div><div id="world">World</div>'); $html->find('div', 1)->class = 'bar'; $html->find('div[id=hello]', 0)->innertext = 'foo'; echo $html; // Output: <div id="hello">foo</div><div id="world" class="bar">World</div> heres what i have thats not workin <?php include("simple_html_dom.php"); // Create DOM from URL or file $html = file_get_html('http://www.aggieathletics.com/sports/m-footbl/sched/tam-m-footbl-sched.html'); $html->find('table[id=schedtable]'); echo $html; ?> it just pulls up the entire page Quote Link to comment Share on other sites More sharing options...
oliverj777 Posted August 21, 2010 Share Posted August 21, 2010 Hummm ... I've never really done this 'DOM' thing before -- give me a minute to play around Quote Link to comment Share on other sites More sharing options...
dadamssg Posted August 21, 2010 Author Share Posted August 21, 2010 alright...this is what i'm attempting to learn from http://simplehtmldom.sourceforge.net/manual.htm Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted August 21, 2010 Share Posted August 21, 2010 You're not echoing the result of the find... you need to put the results in a variable and echo that <?php include("simple_html_dom.php"); // Create DOM from URL or file $html = file_get_html('http://www.aggieathletics.com/sports/m-footbl/sched/tam-m-footbl-sched.html'); $results = $html->find('table[id=schedtable]'); echo $results; ?> At least that would make sense, but I'm not the brightest crayon in the box HTH Quote Link to comment Share on other sites More sharing options...
oliverj777 Posted August 21, 2010 Share Posted August 21, 2010 I can't seem to get my head around this ... I've never done DOMs before - Sorry Quote Link to comment Share on other sites More sharing options...
dadamssg Posted August 21, 2010 Author Share Posted August 21, 2010 still not working..although i can pull something off of one of my own files on my server. This properly displays the heading thats on a different page but still no table from the other site... <?php include("simple_html_dom.php"); // Create DOM from URL or file $html = file_get_html('http://www.aggieathletics.com/sports/m-footbl/sched/tam-m-footbl-sched.html'); $test = $html = file_get_html('http://www.website.com/test/tester.html'); $table = $html->getElementById("schedtable"); $thing = $test->getElementById("heading"); echo "1<br><br>"; echo $table."<br>"; echo "<br>2"; echo "<hr>"; echo "3<br><br>"; echo $thing."<br>"; echo "<br>4"; ?> Quote Link to comment Share on other sites More sharing options...
dadamssg Posted August 21, 2010 Author Share Posted August 21, 2010 success! for anyone that cares this works <?php include("simple_html_dom.php"); // Create DOM from URL or file $html = file_get_html('http://www.aggieathletics.com/sports/m-footbl/sched/tam-m-footbl-sched.html'); $table = $html->getElementById("schedtable"); echo $table; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.