http://www.stallions.com.au/salesresults/sire_results.php?sire_name%5B%5D=Snitzel+%28AUS%29 This table is dynamic table, when I scroll down it follows its own listing but unable to copy the entire table to excel. Please let me know is there a way, I can pay you. Thanks.
How often do you need to pull this, and are there any restrictions on what language? A while back I was pulling data from a similarly laid out site, and I had some PHP that turned the table on the page into CSV. The table on that page is somewhat malformed and not as well organized (TD doing TH's job in THEAD), but at least it HAS thead and tbody. I just ported that simple program I wrote (it's not the cleanest code/implementation, but it works) and it seems to pull the data as proper CSV. If you run this on your hosting or locally under something like XAMPP, it will convert that page into CSV... even forces a download as such. <?php libxml_use_internal_errors(true); // suppress warnings since HTML is shit $doc = new DOMDocument(); $doc->loadHTMLFile( 'http://www.stallions.com.au/salesresults/sire_results.php?sire_name%5B%5D=Snitzel+%28AUS%29', LIBXML_NOWARNING ); function DomNextTag($e, $tagName) { while ($e = $e->nextSibling) { if (isset($e->tagName) && ($e->tagName == $tagName)) return $e; } return false; } function DomFirstTag($e, $tagName) { if ($e = $e->firstChild) do { if (isset($e->tagName) && ($e->tagName == $tagName)) return $e; } while ($e = $e->nextSibling); return false; } function processRows($section) { if ($tr = DomFirstTag($section, 'tr')) { $out = fopen('php://output', 'w'); do { $result = []; if ($td = DomFirstTag($tr, 'td')) do { $result[] = trim($td->textContent); } while ($td = DomNextTag($td, 'td')); fputcsv($out, $result); } while ($tr = DomNextTag($tr, 'tr')); fclose($out); } } header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="table.csv"'); header('Content-Transfer-Encoding: binary'); header('Connection: Keep-Alive'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); $table = $doc->getElementById('derby'); processRows(DomFirstTag($table, 'thead')); processRows(DomFirstTag($table, 'tbody')); ?> Code (markup): Should do the trick. Uses DOMDocument to parse the file, getElementById to isolate the desired table, and then processes rows from both THEAD and TBODY, outputting as valid CSV. (or at least valid enough excel and/or Libreoffice seem to have no issues loading it.) Hope this helps, thankfully I had most of this already written, wasn't too hard to change it for that page's info.
Thanks for your help very much! I'm having trouble running it, I'm using a Mac, I got MAMP installed, copied your code and paste it on a text file and named as index.php. Then I try to go localhost:8888/index.php and it shows up blank. I'm not very good at this please let me know how do I see it? I appreciate your help very much.