Skip to content

Instantly share code, notes, and snippets.

@davehewy
Created April 4, 2013 11:53
Show Gist options
  • Save davehewy/5309773 to your computer and use it in GitHub Desktop.
Save davehewy/5309773 to your computer and use it in GitHub Desktop.
<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
//
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://localhost/table.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"postvar1=value1&postvar2=value2&postvar3=value3");
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
//echo $server_output;
curl_close ($ch);
$parser = new DOMDocument;
$parser->loadHTML($server_output);
foreach($parser->getElementsByTagName('table') as $meta)
{
foreach($meta->getElementsByTagName('tr') as $table_row)
{
foreach($table_row->getElementsByTagName('td') as $table_column)
{
echo $table_column->textContent;
}
}
}
// var_dump($parser);
// var_dump($parser->childNodes);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment