To download the html content:
/* Para no limitar el tiempo de ejecución, se puede demorar */
set_time_limit(0);
$url = "http://urldelsitio";
$html = file_get_contents($url);
$html = fix($html);
$fileName = fileSave("bienes", $html);
$file = fopen($fileName, "r");
Then you iterate the file locating the blocks:
$strContent = "";
$strFile = "";
while (($line_detail = fgets($file)) !== false) {
if (strpos($line_detail, "Subasta:") !== FALSE) {
$strContent .= str_replace("Subasta:", "", line_detail) . ";";
}
/*.... Lo haces para cada linea ..... */
if (strpos($line_detail, "Bien:") !== FALSE) {
$strContent .= str_replace("Subasta:", "", line_detail) . ";";
$strFile .= $strContent . "\n";
$strContent = "";
}
/* al final obtienes la linea separada por comas y así armas el csv */
}
/* Guardas el archivo */
$handlerFileCSV = fopen("file.csv", "a");
fwrite($handlerFileCSV, $strFile);
fclose($handlerFileCSV);
/* Finalmente Importas el archivo a la BD, en la consola de linux o con un batch */
mysql -vvvvv -u admin -pJl@2016.. -h localhost -e "LOAD DATA INFILE '/var/lib/mysql-files/$4' INTO TABLE <tabla> FIELDS TERMINATED BY ';' (<field1, field2, field3, ...>);" <base de datos>
This is an idea of how you can do it, you will understand that it takes time to finish it.
Greetings,