Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- if(!is_array($argv) || !array_key_exists(1,$argv))
- die("Please supply the drive_offsets.html file as an argument.\n");
- $filepath = $argv[1];
- $filedir = dirname($filepath);
- $page=file_get_contents($filepath);
- unset($filedir);
- unset($filepath);
- preg_match("/<table[^>]*>(.+)<\/table>/is", $page, $matches);
- $page=$matches[1];
- preg_match("/<table[^>]*>(.+)<\/table>/is", $page, $matches);
- unset($page);
- $htmldata='<html><body><table>'.$matches[1].'</table></body></html>';
- unset($matches);
- //var_dump($htmldata);
- $doc = new DOMDocument();
- $doc->loadHTML($htmldata);
- $rows = array();
- foreach( $doc->getElementsByTagName( 'tr' ) as $tr ) {
- $cells = array();
- foreach( $tr->getElementsByTagName( 'td' ) as $td ) {
- $cells[] = $td->nodeValue;
- }
- $rows[] = $cells;
- }
- unset($cells);
- unset($doc);
- //var_dump($rows);
- for ($i=1;$i<count($rows);$i++)
- echo "INSERT INTO drives(Name,Offset,Submissions,Percent_agree) VALUES('".$rows[$i][0]."','".$rows[$i][1]."','".$rows[$i][2]."','".$rows[$i][3]."');\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement