Php 如何解析302页眉上的页面?

Php 如何解析302页眉上的页面?,php,parsing,http-status-code-302,Php,Parsing,Http Status Code 302,我必须用php解析一个页面,该页面的url将被移动到302临时标题,并被移动到一个未找到的页面。其数据可以通过mozilla firebug插件的控制台选项手动检索。但如果我尝试用php解析它,它将返回我未找到的页面。我如何解析该页面,请建议 编辑: 我正在做类似的事情来获取页面的内容 $file_results = @fopen("http://www.the url to be parses","rb"); $parsed_results=''; if($file_resul

我必须用php解析一个页面,该页面的url将被移动到302临时标题,并被移动到一个未找到的页面。其数据可以通过mozilla firebug插件的控制台选项手动检索。但如果我尝试用php解析它,它将返回我未找到的页面。我如何解析该页面,请建议

编辑: 我正在做类似的事情来获取页面的内容

$file_results = @fopen("http://www.the url to be parses","rb");
    $parsed_results='';
    if($file_results)
    {
        while ($data3 = fread($file_results,"125000"))
        $parsed_results .= $data3;
    }

您需要读取标头,查看它将您重定向到哪里,并发出另一个请求以获取实际资源。有点痛苦,但这就是协议的工作原理。大多数浏览器都是透明的。

在重定向时,您可以使用查找所有标题

$url = 'http://google.com';
$headers = get_headers($url, 1);

print 'First step gave: ' . $headers[0] . '<br />';

// uncomment below to see the different redirection URLs
// print_r($headers['Location']);

// $headers['Location'] will contain either the redirect URL, or an array
// of redirection URLs
$first_redirect_url = isset($headers['Location'][0]) ?
    $headers['Location'][0] : $headers['Location'];

print "First redirection is to: {$first_redirect_url}<br />";

// assuming you have fopen wrappers enabled...
print file_get_contents($first_redirect_url);
$url='1!'http://google.com';
$headers=get_headers($url,1);
打印“第一步给:”$标题[0]。'
; //取消下面的注释以查看不同的重定向URL //打印($headers['Location']); //$headers['Location']将包含重定向URL或数组 //URL的重定向 $first\u redirect\u url=isset($headers['Location'][0])? $headers['Location'][0]:$headers['Location']; 打印“第一次重定向到:{$First_redirect_url}
”; //假设您已启用fopen包装器。。。 打印文件获取内容($first\u redirect\u url);

继续寻找,直到你得到你想要的资源?

如果你能举出一些例子,我会非常感激你首先使用了什么方法提出请求?我不确定用php做这件事的最佳方式,但这是如何获得实际资源的一般思路。是的,但这不是我想要的……看,我想要的是第一页的内容,而不是重定向页面的内容