file_get_contents

Discussion in 'PHP' started by sergei006, 13 Apr 2013.

  1. sergei006

    sergei006 New Member

    Joined:
    11 Apr 2013
    Messages:
    23
    Likes Received:
    0
    Reputations:
    0
    <?php
    $kopirovanie = file_get_contents("http://..........");
    file_put_contents("katalog/151.txt", $kopirovanie);
    ?>

    Warning: file_get_contents(http://.../) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 418 in C:\Program Files\Apache Software Foundation\Apache2.0\htdocs\index.php on line 4

    Как обойти.?
     
  2. mrDebian

    mrDebian Member

    Joined:
    27 Jan 2013
    Messages:
    96
    Likes Received:
    13
    Reputations:
    10
    "418 I'm a teapot"

    Попробуй user-agent установить нормальный.
     
  3. sergei006

    sergei006 New Member

    Joined:
    11 Apr 2013
    Messages:
    23
    Likes Received:
    0
    Reputations:
    0
    Спасибо mrDebian

    Opera/9.80 (Windows NT 5.1) Presto/2.12.388 Version/12.14
     
  4. fl00der

    fl00der Moderator

    Joined:
    17 Dec 2008
    Messages:
    1,027
    Likes Received:
    311
    Reputations:
    86
    А вот теперь внимание. У тебя это стоит в твоем браузере? Если так, то это бесполезно, а как сменить User Agent File_get_contents я даже не знаю.
    Да и про ошибку что-то мало где написано.
     
    _________________________
  5. mrDebian

    mrDebian Member

    Joined:
    27 Jan 2013
    Messages:
    96
    Likes Received:
    13
    Reputations:
    10
    PHP:
    ini_set("user_agent""Your browsername here");
     
    1 person likes this.
  6. fl00der

    fl00der Moderator

    Joined:
    17 Dec 2008
    Messages:
    1,027
    Likes Received:
    311
    Reputations:
    86
    Мистер Дебиан, спасибо.
     
    _________________________
  7. daniel777

    daniel777 Elder - Старейшина

    Joined:
    8 Jul 2010
    Messages:
    517
    Likes Received:
    90
    Reputations:
    37
    Для передачи заголовков (в том числе и user agent) можно использовать функцию stream_context_create()