2014-10-16 7 views
0

나는이 웹 사이트의 (xml aparently) 내용을 얻으려고합니다 : http://gestis.itrust.de/nxt/gateway.dll/gestis_de/010520.xml?f=templates$fn=default-doc.htm$3.0 PHP 또는 PHP의 file_get_contents를 통해.gestis 데이터베이스 xml 가져 오기

모든 브라우저에서 웹 사이트를 열 수 있지만 PHP로 열려고 할 때마다 자동으로 콘텐츠를 가져 오면 500 오류가 반환됩니다. 여기

은 코드가 사용됩니다 :

<?php 

/* gets the data from a URL */ 
function get_data($url) { 
    $ch = curl_init(); 
    $timeout = 5; 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
    curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
    $data = curl_exec($ch); 
    curl_close($ch); 
    return $data; 
} 

$returned_content = get_data('http://gestis.itrust.de/nxt/gateway.dll/gestis_de/010520.xml?f=templates$fn=default-doc.htm$3.0'); 

echo $returned_content; 

?> 

는 사람이 어떻게 웹 사이트에서 PHP를 통해 XML을 얻는 아이디어가 있습니까?

+0

. 더구나, 당신이 제공 한 링크는 XML 리소스가 아니라'당신이 찾고있는 리소스가 제거되었거나, 이름이 변경되었거나, 일시적으로 사용할 수 없습니다. '라고 말했습니다. – Ohgodwhy

+0

아 나는 그것을 쓰는 forgto. 링크를 통해 먼저 열면 콘텐츠 만 제공됩니다. http://gestis.itrust.de/nxt/gateway.dll?f=id$t=default-doc.htm$vid=gestisdeu:sdbdeu$ id = 010520 –

+0

XML 파일이 아니기 때문에 ... – Ohgodwhy

답변

0

열려는 웹 사이트가 작동하는 쿠키의 형태로 vid=gestisdeu:sdbdeu 값을 필요 :

Cookie: nxt/gateway.dll/vid=gestisdeu%3Asdbdeu; 

쿠키를 설정하거나 이미 기존의 재료에 좀 걸릴 수 있습니다 방법 컬 설명서를 참조하십시오 이 webiste에, 예를 들면 Is it possible to set the cookie content with CURL? 등.

웹 사이트 및 구성 변경에 따라 달라질 수 있습니다. 그래서 기술적으로 귀하의 질문에 대한 답변을 얻을 수 없습니다. 웹 사이트에는 HTTP 요청 요구 사항에 대한 문서가 없기 때문입니다. 그런 질문을하면 스스로 찾아 내서 제공해야합니다.

PHP 예 :

$url = 'http://gestis.itrust.de/nxt/gateway.dll/gestis_de/010520.xml?f=templates$fn=default-doc.htm$3.0'; 
$options['http'] = ['header' => 'Cookie: nxt/gateway.dll/vid=gestisdeu%3Asdbdeu;']; 
stream_context_set_default($options); 
$content = file_get_contents($url); 
var_dump($content); 

출력 : 두 컬 초기화 호출 한 함수에 싸여 하나가 사용되지 않는 기능에 싸여하지가 않습니다 왜

string(104975) "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<title>DGUV-IFA GESTIS</title> 
    <meta http-equiv="content-type" content="text/html;charset=utf-8"> 
</head> 
<body> 
    <html> 
<head> 
<META http-equiv="Content-Type" content="text/html"> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<link rel="stylesheet" href="/nxt/gateway.dll/gestis_de/010520.xml?f=stylesheets$fn=gestis-doc.css$up=1$3.0" type="text/css"> 
<"...