Jump to content

pull other sites html??


dadamssg

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/211277-pull-other-sites-html/
Share on other sites

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????

?>

 

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

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

 

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... :confused:

<?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";

?>

 

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;


?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.