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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
<?php
require_once 'simple_html_dom.php';
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; /* on définie les options d'erreurs que l'on souhaite */
$bdd = new PDO("mysql:host=127.0.0.1;dbname=Acteurs;charset=utf8", '', '', $pdo_options);
$total_execute = 91;
for($i = 2 ; $i <= $total_execute ; $i++){
$url = 'https://fqdn/'.$i'./?sort_by=rating&items_per_page=98';
$html = new simple_html_dom();
$html->load_file($url);
function remplace_les_mois($phrase){
$origine = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October","November","December");
$remplace = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Décembre");
$newphrase = str_replace($origine, $remplace, $phrase);
return $newphrase;
}
function remplace_les_cheveux($phrase){
$origine = array("Bald", "Brown", "Bleached", "Blond", "Black", "Grey", "Red");
$remplace = array("Chauve", "Brune", "Blanc", "Blonde", "Noir", "Gris", "Rousse");
$newveuch = str_replace($origine, $remplace, $phrase);
return $newveuch;
}
function remplace_nationalite($phrase){
$origine = array("Argentinian", "Australian", "Austrian", " Belarussian", " Belgian", "Brazilian ", "Canadian", "Costa Rican", "Czech", "Danish", "Estonian", "Finnish", "French", "German", "American", " Hungarian", "Indonesian", "Japanese");
$remplace = array("Argentine", "Australienne", "Autrichienne", "Biélorusse", "Belge", "Brésilienne", "Canadienne", "Costaricaine", "Tchèque", "Danoise", "Estonienne", "Finlandaise", "Française", "Allemande", "Américaine", "Hongroise", "Indonésienne", "Japonaise");
$newnation = str_replace($origine, $remplace, $phrase);
return $newnation;
}
//}
$i=0;
foreach($html->find('.models-list-item') as $article) {
$item['nom'] = $html->find('p.title', $i)->plaintext;
$item['date de naissance'] = $html->find('ul.model-info-list', $i)->children(0)->plaintext;
$item['Lieu de naissance'] = $html->find('ul.model-info-list', $i)->children(1)->plaintext;
$item['De'] = $html->find('ul.model-info-list', $i)->children(2)->plaintext;
$item['Genre'] = $html->find('ul.model-info-list', $i)->children(3)->plaintext;
$item['Nationalité'] = $html->find('ul.model-info-list', $i)->children(4)->plaintext;
$item['Cheveux'] = $html->find('ul.model-info-list', $i)->children(5)->plaintext;
$item['infos'] = $html->find('ul.model-info-list', $i)->children(6)->plaintext;
$item['photos']= $html->find('img.thumb', $i)->src;
$item['id'] = $html->find('a.thumb-model-link', $i)->href;
$articles[] = $item;
$i++;
$id_nom = substr($item['id'], 13);
$id_actrice = substr($item['id'], 8, 4);
echo $id_actrice.'</b>';
echo '<b>'.$item['nom'].'</b><br />';
$nom = $item['nom'];
$texte = htmlspecialchars($item['date de naissance']);
$date = str_replace('Birthday', 'Date de Naissance', $texte);
$new_date = remplace_les_mois($date);
echo $new_date.'<br />';
$texte2 = htmlspecialchars($item['Lieu de naissance']);
$ville = str_replace('Birthplace', 'Ville de Naissance', $texte2);
echo $ville.'<br />';
$texte3 = htmlspecialchars($item['De']);
$active = str_replace('Years Active', 'Active de', $texte3);
$actives = str_replace('-', 'à', $active);
echo $actives.'<br />';
$texte4 = htmlspecialchars($item['Genre']);
$Ethnicity = str_replace('Ethnicity', 'Ethnicité', $texte4);
echo $Ethnicity.'<br />';
$texte5 = htmlspecialchars($item['Nationalité']);
$Nationalite = str_replace('Nationality/Heritage', 'Nationalité', $texte5);
$newnationalite = remplace_nationalite($Nationalite);
echo $newnationalite.'<br />';
$texte6 = htmlspecialchars($item['Cheveux']);
$Couleurs = str_replace('Hair Color', 'Couleurs de cheveux', $texte6);
$newcouleurs = remplace_les_cheveux($Couleurs);
echo $newcouleurs.'<br />';
$texte7 = htmlspecialchars($item['infos']);
$films = str_replace('Films:', '', $texte7);
$film = 'Films: <a href="http://fqdn/search/?q='.$id_nom.'">'.$films.'</a><br />';
$photos = '<img src='.$item['photos'].' alt="'.$item['nom'].'"><br /><br />';
$requete = $bdd->prepare('INSERT INTO `Actrices`(`id_actrice`, `nom`, `date_de_naissance`,`de`, `ville`, `genre`, `nationalite`, `cheveux`, `infos`, `photos`) VALUES (:id_actrice, :nom, :date_de_naissance, :de, :ville, :genre, :nationalite, :cheveux, :infos, :photos)');
$requete->execute(array(':id_actrice'=>$id_actrice, ':nom'=>$nom, ':date_de_naissance'=>$new_date, ':de'=>$actives, ':ville'=>$ville , ':genre'=>$Ethnicity, ':nationalite'=>$newnationalite, ':cheveux'=>$Couleurs, ':infos'=>$film, ':photos'=>$photos));
}
}
?> |
Partager