@ree4i

Ошибка при парсинге, спасайте?

Мой код:
set_time_limit(0);
ini_set( 'memory_limit', '256M' );

include $_SERVER['DOCUMENT_ROOT']."/simple_html_dom.php";

function parse($url){
	$uagent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"; 
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_USERAGENT, $uagent);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
	curl_setopt($ch, CURLOPT_COOKIEJAR,$_SERVER['DOCUMENT_ROOT']."/data/cookie.txt");
	curl_setopt($ch, CURLOPT_COOKIEFILE,$_SERVER['DOCUMENT_ROOT']."/data/cookie.txt");
	$data = iconv('CP1251', 'UTF-8', curl_exec($ch));
	curl_close($ch);
	return $data;
}

echo str_get_html(parse($url));

Выводит над страницей парсера:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

    Line 343:        string AcceptEncoding = HttpContext.Current.Request.Headers["Accept-Encoding"];  Line 344:  Line 345:        if (!string.IsNullOrEmpty(AcceptEncoding) &&  Line 346:  Line 347:             AcceptEncoding.Contains("gzip") || AcceptEncoding.Contains("deflate"))


Source File: d:\inetpub\vhosts\filmitena.com\httpdocs\MasterPage.master.cs    Line: 345

Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]     MasterPage.IsGZipSupported() in d:\inetpub\vhosts\sdgf.com\httpdocs\MasterPage.master.cs:345     MasterPage.GZipEncodePage() in d:\inetpub\vhosts\sdgf.com\httpdocs\MasterPage.master.cs:319     MasterPage.Page_Load(Object sender, EventArgs e) in d:\inetpub\vhosts\sdgf.com\httpdocs\MasterPage.master.cs:25     System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51     System.Web.UI.Control.OnLoad(EventArgs e) +92     System.Web.UI.Control.LoadRecursive() +54     System.Web.UI.Control.LoadRecursive() +145     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772  

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34249
  • Вопрос задан
  • 467 просмотров
Решения вопроса 1
@ree4i Автор вопроса
Все, вопрос снят, утопающий вытащил себя за волосы ))
Оказалось, что удотная iconv идет нафиг, а вместо нее в дело вступает CURLOPT_ENCODING )
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы