Jump to content

using php sockets


pouncer

Recommended Posts

ok guys, I had a go at this but no luck!

 


<?php

$host = "www.onelook.com";

$fp = fsockopen($host, 80, $errno, $errdesc) or die("Connection to $host failed");



$request = "GET /w=cat&ls=a HTTP/1.0\r\n";

$request .= "Host: $host\r\n";

$request .=  "Accept-Language: en-us\r\n";

   $request .=  "Accept-Encoding: gzip, deflatez\r\n";

$request .= "Accept: */*\r\n\r\n";



fputs($fp, $request);



while(!feof($fp)){

  $page[] = fgets($fp, 1024);

}



fclose($fp);

echo "The server returned ".(count($page)). " Lines";



for($i=0; $i<count($page); $i++){

  echo $page[$i];

}

?>

 

 

 

Try to conect for e.g: http://www.onelook.com/?w=cat&ls=a

 

 

 

It just keeps giving me a 302 error. What I'm actually looking to do is to check on the right of the page where it says

 

 

 

Quick definitions (cat)

 

 

 

 

 

noun: feline mammal usually having thick soft fur and being unable to roar; domestic cats; wildcats

 

 

 

It it finds that the word is a noun and or an adjective, I just want it to return/halt and echo "Word is a noun" etc

 

 

 

can anyone help?

 

Link to comment
https://forums.phpfreaks.com/topic/45166-using-php-sockets/#findComment-219307
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.