par
josse34 » 18 janv. 2014, 19:06
Alors, déjà comme conseillé sur
http://www.seoblackout.com/2008/02/13/s ... ormulaire/ , j'ai téléchargé l’excellent plugin webdeveloper et voila ce que ca me sort correctement remplis :
PVREST.jpg
à savoir ce tableau la en pdf :
http://cjoint.com/?3AssS5H046C
On reprends le php avec CURL, et CA FONCTIONNE malgré un souci de fichier, j'obtiens l'erreur
Warning: the system could not read the horizon file supplied, using standard horizon, en fait je fais passer $postfields["horizonfile"] = ""; pour un field alors qu'il faudrais lui dire que c'est un fichier et qu'il n'y en a pas!
Comment faire? CurlFile?
Reste maintenant à recuperer les données qui m'interresse dans 12 lignes comme celle ci :
<tr> <td> Jan </td><td align="right">6.39</td><td align="right">198</td><td align="right">2.77</td><td align="right">85.9</td></tr>
Il n'existe pas une sorte de Explode pour ne sortir que les chiffres dans cette ligne sachant que Jan sera toujours le même?
Merci!
<?php
$postfields = array();
$postfields["action"] = "submit";
$postfields["MAX_FILE_SIZE"] = "10000";
$postfields["pv_database"] = "PVGIS-CMSAF";
$postfields["pvtechchoice"] = "crystSi";
$postfields["peakpower"] = "3";
$postfields["efficiency"] = "14";
$postfields["mountingplace"] = "building";
$postfields["angle"] = "35";
$postfields["aspectangle"] = "10";
$postfields["horizonfile"] = "";
$postfields["outputchoicebuttons"] = "window";
$postfields["sbutton"] = "Calculate";
$postfields["outputformatchoice"] = "window";
$postfields["optimalchoice"] = "";
$postfields["latitude"] = "43.570274";
$postfields["longitude"] = "4.064435";
$postfields["regionname"] = "europe";
$postfields["language"] = "en_en";
$url = "http://goo.gl/cjwe8E";
$useragent = "Mozilla/5.0";
$referer = $url;
//Initialise une session CURL
$ch = curl_init($url);
//CURL options
curl_setopt($ch, CURLOPT_POST, 1);
//On poste les données du tableau $postfields
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
//On définit un useragent ici Mozilla/5.0
//souvent les bots se font passés pour googlebot ce qui finalement est stupide
//On passe donc un useragent banal
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
//On passe un referrer ici on passe la même page $url
curl_setopt($ch, CURLOPT_REFERER, $referer);
//on récupère le contenu de la page de résultat de la soumission dans une chaine
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// en cas de redirection (facultatif ici)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//Page de résultats et fermeture de session
$result = curl_exec($ch);
curl_close($ch);
//on peut faire un echo du résultat obtenu
echo $result;
//var_dump($result)
?>
Alors, déjà comme conseillé sur http://www.seoblackout.com/2008/02/13/soumission-automatique-formulaire/ , j'ai téléchargé l’excellent plugin webdeveloper et voila ce que ca me sort correctement remplis :
[attachment=0]PVREST.jpg[/attachment]
à savoir ce tableau la en pdf : http://cjoint.com/?3AssS5H046C
On reprends le php avec CURL, et CA FONCTIONNE malgré un souci de fichier, j'obtiens l'erreur [color=#FF0000]Warning: the system could not read the horizon file supplied, using standard horizon[/color], en fait je fais passer $postfields["horizonfile"] = ""; pour un field alors qu'il faudrais lui dire que c'est un fichier et qu'il n'y en a pas! [b]Comment faire? CurlFile?[/b]
Reste maintenant à recuperer les données qui m'interresse dans 12 lignes comme celle ci :
<tr> <td> Jan </td><td align="right">6.39</td><td align="right">198</td><td align="right">2.77</td><td align="right">85.9</td></tr>
[b]Il n'existe pas une sorte de Explode pour ne sortir que les chiffres dans cette ligne sachant que Jan sera toujours le même?[/b]
Merci!
[php]
<?php
$postfields = array();
$postfields["action"] = "submit";
$postfields["MAX_FILE_SIZE"] = "10000";
$postfields["pv_database"] = "PVGIS-CMSAF";
$postfields["pvtechchoice"] = "crystSi";
$postfields["peakpower"] = "3";
$postfields["efficiency"] = "14";
$postfields["mountingplace"] = "building";
$postfields["angle"] = "35";
$postfields["aspectangle"] = "10";
$postfields["horizonfile"] = "";
$postfields["outputchoicebuttons"] = "window";
$postfields["sbutton"] = "Calculate";
$postfields["outputformatchoice"] = "window";
$postfields["optimalchoice"] = "";
$postfields["latitude"] = "43.570274";
$postfields["longitude"] = "4.064435";
$postfields["regionname"] = "europe";
$postfields["language"] = "en_en";
$url = "http://goo.gl/cjwe8E";
$useragent = "Mozilla/5.0";
$referer = $url;
//Initialise une session CURL
$ch = curl_init($url);
//CURL options
curl_setopt($ch, CURLOPT_POST, 1);
//On poste les données du tableau $postfields
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
//On définit un useragent ici Mozilla/5.0
//souvent les bots se font passés pour googlebot ce qui finalement est stupide
//On passe donc un useragent banal
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
//On passe un referrer ici on passe la même page $url
curl_setopt($ch, CURLOPT_REFERER, $referer);
//on récupère le contenu de la page de résultat de la soumission dans une chaine
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// en cas de redirection (facultatif ici)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//Page de résultats et fermeture de session
$result = curl_exec($ch);
curl_close($ch);
//on peut faire un echo du résultat obtenu
echo $result;
//var_dump($result)
?>
[/php]