Correction renvoi 302

This commit is contained in:
Michael RICOIS 2012-03-21 08:08:49 +00:00
parent 2ffad42a76
commit 489a1f7c2a

View File

@ -295,7 +295,7 @@ if ( $opts->commandes )
/**************************************************
Documents commandés
**************************************************/
$url = "http://www.infogreffe.fr//infogreffe/afficherMesAchats.do?refCde=N";
$url = "http://www.infogreffe.fr/infogreffe/afficherMesAchats.do?refCde=N";
$result = getPage($url);
if (DEBUG) file_put_contents('documents.html', $result['content']);
@ -441,7 +441,7 @@ if ( $opts->siren )
// 302 Moved Temporarily
//http://www.infogreffe.fr/infogreffe/entrepListe.do?index=rcs
if ( $result['header']['http_code']=='302' ) {
if ( $result['header']['http_code']=='302' && array_key_exists('redirect_url', $result['header']) ) {
$url = $result['header']['redirect_url'];
$result = getPage($url);
if (DEBUG) file_put_contents('kbis3-1.html', print_r($result,1));
@ -454,11 +454,15 @@ if ( $opts->siren )
$xpath = new DOMXpath($doc);
$nodelist = $xpath->query("//a[@class='company']");
foreach ($nodelist as $n) {
echo $url = 'http://www.infogreffe.fr'. $n->getAttribute('href');
$url = 'http://www.infogreffe.fr'. $n->getAttribute('href');
break;
}
$result = getPage($url);
if (DEBUG) file_put_contents('kbis3-2.html', print_r($result,1));
} elseif ( $result['header']['http_code']=='302' ) {
$url = 'http://www.infogreffe.fr/weblogic/infogreffe/entrepListe.do?index=rcs';
$result = getPage($url);
if (DEBUG) file_put_contents('kbis3-1.html', print_r($result,1));
}
$doc = new DOMDocument();