...

View Full Version : Http sockets



avelonx
07-18-2002, 07:16 PM
I want to open an http socket in php , search the web document for the 2ND "<font color="#FFFFFF" size="+2"><span style="font-size:24"><br>" and the 2ND "</span></font></b></td>"

1. a <br> 2. b <br> 3. C is between them




i want it to remove all the "<br>" inbetween and somehow put it in a variable like this
------------
1.A
2.B
3.C
------------


so if i were to echo the variable it would return

1.a
2.b
3.c


COuld someone please show me hwo to do so?

Socraties
07-19-2002, 08:42 PM
$remote = "your.server.address.ordomain";
$proto = 8003;
//echo "Remote Host is: $remote<p>";
$service_port = getprotobyname('tcp');
$address = gethostbyname($remote);

$socket = socket(AF_INET, SOCK_STREAM, $service_port);
if($socket){
echo "socket has connected<p>";
}
$try = connect($socket,$address, $proto);
$Command = "What you want sent through the socket here\r\n";
$result = '';
//Read and Write thorugh socket.
write($socket, $Command, strlen($Command));
read($socket,$result,256);
close($socket);



Ok how this works is it opens up a connection based on port, which i have set at 8003 but can be any (should be 80 or 443 in your case). The rest of the stuff is pretty standard socket connection stuff. The $Command would be a string array comma deliminated or any other type of format to be sent through the socket. The write command then writes the value of $Command through the socket. The read command reads what is sent back through the socket and stuff it into the $result variable.

In the result variable is where you would be able to strip out values that you don't want and display the data how you want it to be displayed. I hope this helps ya get started anyways.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum