문제

Curl은 Curlopt_FollowLocation을 사용하여 헤더 리디렉션을 따라갈 수 있지만 Meta Refresh Redirects를 따라갈 수 있습니까?

감사

도움이 되었습니까?

해결책

예,하지만 응답을 구문 분석하고 모양을 찾아서 직접해야합니다.

<meta http-equiv="refresh" content="5;url=http://example.com/" />

추종 <meta> 새로 고침 요청은 브라우저 측입니다. Dom Parsing을 사용하여 찾으십시오 <meta> 응답 컬에 적절한 속성이있는 태그가 제공됩니다.

응답이 유효한 XML임을 보장 할 수 있다면 다음과 같은 작업을 수행 할 수 있습니다.

$xml = simplexml_load_file($cURLResponse);
$result = $xml->xpath("//meta[@http-equiv='refresh']");
// Process the $result element to get the relevant bit out of the content attribute
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top