Re: Recieve information on a html site using php?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for the response,

I think I have solved the problem using the code in the attached text document.

Thanks for the help,
Marc

Roman Neuhauser wrote:
# marc.roberts@xxxxxxxxxxxxxxxx / 2006-10-18 17:23:53 +0200:
Is it possible to receive information on a html site, such as the
language, date modified?

If so how would I go about doing this?
Your question is very vague, so I'm taking the liberty of
    interpretation.

    - ftp://ftp.rfc-editor.org/in-notes/rfc2616.txt
    - http://www.php.net/http
      (haven't used pecl_http myself, you might have to resort to
      http://www.php.net/sockets)


function get_raw_header($host,$doc)
	{
		$httpheader = '';
		$fp = fsockopen ($host, 80, $errno, $errstr, 30);
		if (!$fp)
		{
			echo $errstr.' ('.$errno.')';
		}else{
			fputs($fp, 'GET '.$doc.' HTTP/1.0'."\r\n".'Host: '.$host."\r\n\r\n");
			while(!feof($fp))
			{
				$httpresult = fgets ($fp,1024);
				$httpheader = $httpheader.$httpresult;
				if (ereg("^\r\n",$httpresult))
				break;
			}
			fclose ($fp);
		}
		return $httpheader;
	}
	
	function get_header_array($Url)
	{
		$Url = ereg_replace('http://','',$Url);
		$endHostPos = strpos($Url,'/');
		if(!$endHostPos) $endHostPos = strlen($Url);
		$host = substr($Url,0,$endHostPos);
		$doc = substr($Url,$endHostPos,strlen($Url)-$endHostPos);
		if($doc == '') $doc = '/';
		$raw = get_raw_header($host,$doc);
		$tmpArray = explode("\n",$raw);
		for ($i=0;$i<sizeof($tmpArray); $i++)
		{
			@list($Name, $value) = explode(':', $tmpArray[$i], 2);
			$array[trim($Name)]=trim($value);
		}
		return $array;
	}
	
	$remote_file = 'http://www.whatever.com/';//states which url to read the modified date from
	$array = get_header_array($remote_file);//gets the data on the page $remote_file
		$deUpdate = date('Ymj',strtotime($array['Last-modified']));
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux