1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| function table_but_exact($lien_exact)
{
foreach ($lien_exact as $lien2) {
$html = new simple_html_dom();
$html->load_file($lien2);
$csv = [];
$tr = $html->find('#btable', 0);
foreach ($tr->find('tr') as $item) {
$td = $item->find("td");
$temp = [];
for ($i = 0; $i < sizeof($td); $i++) {
if ($i <> 2) {
$text = $td[$i]->text();
$text = trim($text);
$text = str_replace(",", "", $text);
$text = str_replace("%", "", $text);
$text = str_replace(" ", "", $text);
$text = str_replace('(', "", $text);
$text = str_replace(')', "", $text);
array_push($temp, $text);
}
}
if (sizeof($td) > 8) {
$csv[] = $temp;
}
}
$pdo = new PDO('mysql:host=localhost;dbname=resultat_stats', 'root', '');
foreach ($csv as $data) {
$ajouter = "INSERT INTO but_exact VALUE '.$data.'";
$preparedajouter = $pdo->prepare($ajouter);
$preparedajouter->execute();
}
}
} |
Partager