Ustag Posted March 10, 2012 Report Share Posted March 10, 2012 (edited) Hello, im trying to use socks to grab only time and the "killed by" text from the character deaths from this page:http://www.tibia.com...ters&name=Apaci I use this code and ofc it gives me the whole page, now how can I filter what I get so that I only get the parts that I want? $fp = fsockopen("www.tibia.com", 80, $errno, $errstr, 30);if (!$fp){ echo "$errstr ($errno)<br />\n";}else{$out = "GET /community/?subtopic=characters&name=Apaci HTTP/1.1\r\n";$out .= "Host: www.tibia.com\r\n";$out .= "Connection: Close\r\n";$out .= "Accept: text/plain\r\n\r\n"; fwrite($fp, $out);$lines = Array();while (!feof($fp)){ $lines[] = fgets($fp, 1024);} for($i=0; $i<count($lines); $i++){ echo $lines[$i];} fclose($fp); } Edited March 10, 2012 by Ustag Link to comment Share on other sites More sharing options...
birbal Posted March 10, 2012 Report Share Posted March 10, 2012 You can capture part of text using preg_replace() ..or you can use http://php.net/DOM also for that. Link to comment Share on other sites More sharing options...
boen_robot Posted March 10, 2012 Report Share Posted March 10, 2012 Do you have to use sockets? You could simply use DOMDocument's loadHTMLFile() method, or a plain fopen() call, combined with PCRE. Link to comment Share on other sites More sharing options...
Ustag Posted March 10, 2012 Author Report Share Posted March 10, 2012 I'm experimenting with socks, learning this and that ^^ but thank you both. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now