Permalink
Browse files

исправлен парсинг ozon (информация о фильме)

  • Loading branch information...
macondos committed Aug 6, 2011
1 parent 957dc64 commit 211813213a7f09655c781e3d68eebe6c0b4c4061
Showing with 12 additions and 3 deletions.
  1. +9 −0 src/common/http.php
  2. +1 −1 src/common/webparser/modules/ozon.php
  3. +2 −2 src/common/webparser/webparser.php
View
@@ -526,6 +526,15 @@ function get( $uri, $follow_redirects = true, $referer = '', $returnRawResponse
while (!feof( $this->_socket )) {
$response .= fread( $this->_socket, 4096 );
}
if (preg_match('{^HTTP/\d\.\d\s+(\d+)}i', $response, $matches )) {
$status = $matches[1];
if ( $follow_redirects && ($status == HTTP_STATUS_MOVED_PERMANENTLY || $status == HTTP_STATUS_FOUND || $status == HTTP_STATUS_SEE_OTHER ) ) {
if (preg_match('{' . HTTP_CRLF . 'Location:(.*?)' . HTTP_CRLF . '}i', $response, $matches )) {
$location = trim($matches[1]);
return $this->get($location, $follow_redirects, $uri, $returnRawResponse, $gzipEnable);
}
}
}
return $response;
} else {
$this->_get_response();
@@ -59,7 +59,7 @@ function parse($path, $what){
$dirPath = dirname($path);
$url = $this->absUrl($path, $dirPath);
$fullCastPath = preg_match("/\?type=1/i", $url)? $url : $url . '?type=1';
$res = $this->getStructByUrl($fullCastPath, 'ozon', $what);
$res = $this->getStructByUrl($fullCastPath, 'ozon', $what, array(), true);
break;
case "person":
$dirPath = dirname($path);
@@ -130,7 +130,7 @@ function getHttpRetriever($path){
return $httpClient;
}
function getStructByUrl($url, $module, $context, $acceptedAttaches = array())
function getStructByUrl($url, $module, $context, $acceptedAttaches = array(), $followRidrects = false)
{
$res = false;
$request = array(
@@ -145,7 +145,7 @@ function getStructByUrl($url, $module, $context, $acceptedAttaches = array())
$res = $result['response'];
} elseif (in_array($result['response'], array(404,500))) {
$httpClient = $this->getHttpRetriever($url);
$response = $httpClient->get($url, true, '', true, true);
$response = $httpClient->get($url, $followRidrects, '', true, true);
$request['action'] = 'parseResponse';
$request['response'] = $response;
$result = $this->execServiceAction($request);

0 comments on commit 2118132

Please sign in to comment.