Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // ini_set('display_errors', 1);
- // ini_set('display_startup_errors', 1);
- // error_reporting(E_ALL);
- $htmlContent = file_get_contents("https://en.wikipedia.org/wiki/Template:2019–20_coronavirus_pandemic_data");
- $DOM = new DOMDocument();
- $DOM->loadHTML($htmlContent);
- $Header = $DOM->getElementsByTagName('th');
- $Detail = $DOM->getElementsByTagName('td');
- //#Get header name of the table
- foreach($Header as $NodeHeader)
- {
- $aDataTableHeaderHTML[] = trim($NodeHeader->textContent);
- }
- $th3 = $aDataTableHeaderHTML;
- $th2 = array_slice($th3, 11);
- $th1 = array_slice($th2, 0, 435);
- $th = array_values(array_filter($th1, 'strlen'));
- //print_r($th); //- Only country names
- //#Get row data/detail table without header name as key
- foreach($Detail as $sNodeDetail)
- {
- $aDataTableDetailHTML[] = trim($sNodeDetail->textContent);
- }
- $td1 = array_slice($aDataTableDetailHTML, 0, 871);
- $td = array_chunk($td1, 4);
- //print_r($td); // - Only country results without names
- ?>
Add Comment
Please, Sign In to add comment