From 489a1f7c2a860de956f325b0009ea1912ae38861 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Wed, 21 Mar 2012 08:08:49 +0000 Subject: [PATCH] Correction renvoi 302 --- batch/getKbis.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/batch/getKbis.php b/batch/getKbis.php index 6eca51fb..61613fef 100644 --- a/batch/getKbis.php +++ b/batch/getKbis.php @@ -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();