Answer the question
In order to leave comments, you need to log in
How to parse a table?
Hello!
On one site there is a table with such code.
There is another code before and after it. How can this table be parsed entirely in PHP?
It means that a piece of table code will be completely torn out of that page and inserted into the page being opened.
Thanks for your advice :)
Answer the question
In order to leave comments, you need to log in
$ch = curl_init();
curl_setopt_array($ch,
array(
CURLOPT_URL => 'example.com',
CURLOPT_HEADER => false,
CURLOPT_FAILONERROR => true,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FORBID_REUSE => true
));
$source = curl_exec($ch);
curl_close($ch);
$dom = new DOMDocument();
$dom->loadHTML($source);
$tables = $dom->getElementsByTagName('table');
...
...
...
echo $dom->saveXML();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question