Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SNOOPY when URL is Redirected

Status
Not open for further replies.

chvol

Programmer
Oct 3, 2002
25
US
I am writing a program in PHP that accesses the HTML of a given URL via class SNOOPY. However, some URLs change into another one e.g. becomes if you connect to it. How can I tell that this URL changes like that? I think it is called “redirecting”. Is it in the HTML? I need to know what the new URL is in order to translate HREF= into the complete URL. Charlie chvol@aol.com
 
There are three major methods by which a browser can be redirected to a new URL:[ul][li]throught the use of the "Location:" HTTP header.[/li][li]through the use of the <META...> tag which includes the "http-equiv" attribute of "refresh" in the HTML body of the page[/li][li]client-side scripting[/li][/ul]




Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks, but it doesn't seem to be anywhere in the HTML. So how can I see what the client is translating it into?

Charlie
 
ingresman:
HTTP_REFERER is only set for connections coming into a server.

chvol:
The Snoopy class uses class collect and provide access to the HTTP headers a server sends when you use the class to fetch a page? If so, look there for a header beginning "Location:"



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
chvol:
A quick peak of the Snoopy script code shows the lines:

Code:
var	$headers		=	array();			// headers returned from server sent here

Code:
var	$status			=	0;					// http request status

When your script connects to a site with Snoopy, have that script examine $status. If it is 302, then the $header array should contain a "Location:" header.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top