richiec Posted July 5, 2007 Share Posted July 5, 2007 Hey, i am quite new to php and i have been stuck on this topic now for a few days and i can not seem to get my head around it so any help you guys can give me will be of great help and much appreciated. This is what i am trying to do. a code which will parse a specified URL for a table name and then print everything back that it finds within that table. Thanks Rich. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 5, 2007 Share Posted July 5, 2007 So you are looking to get the contents of another website, find a table within that website, and print out that particular table? Depending on the website you are getting the contents from, you can either use file_get_contents() or you may have to use cURL and php. Once you have the contents of the page in a variable, you will need to use regular expressions to find your particular table. The preg_match() function is what you'll need. To be able to give you any more help, we're probably going to need a bit more detail. Quote Link to comment Share on other sites More sharing options...
richiec Posted July 5, 2007 Author Share Posted July 5, 2007 That's exactly what i am trying to do yes. As i said though i am quite new to php, would it be possible for you to write the code out as an example of how to do that? Thanks Rich. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 5, 2007 Share Posted July 5, 2007 Well i dont think anyone is just going to do something for you. And like i said, we'd need to know a bit more information about what you are trying to do before we can help you. What is the site that you are trying to get information from? Quote Link to comment Share on other sites More sharing options...
richiec Posted July 5, 2007 Author Share Posted July 5, 2007 I am not really sure what more information i can give, all im trying to do is to look for a table name on a game site which is http://outwar.com and then it prints out everything listed in the table. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 5, 2007 Share Posted July 5, 2007 Right. And do you need to be logged in to view that table? Quote Link to comment Share on other sites More sharing options...
per1os Posted July 5, 2007 Share Posted July 5, 2007 <?php $file = file_get_contents("http://outwar.com"); list($before, $after) = split("<table tag here>">, $file); list($table) = split("</end table tag here", $after); echo $table; ?> There is an example, replace what you are searching for in the first parameter of www.php.net/split Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 5, 2007 Share Posted July 5, 2007 Frost100 - i really dont think its going to be that simple. If you take a look at the website, there is very little on it - im guessing the table that is wanted is a table you can only see once logged in. In which case, cURL will be needed. Quote Link to comment Share on other sites More sharing options...
per1os Posted July 5, 2007 Share Posted July 5, 2007 Frost100 - i really dont think its going to be that simple. If you take a look at the website, there is very little on it - im guessing the table that is wanted is a table you can only see once logged in. In which case, cURL will be needed. Probably not, but that part doesn't matter to me whether he gets it from cURL or not. He asked for an example to his question, that is how you would parse a remote site. Either way it is an example, if he has to use curl the same would apply, you would just have to use curl commands to get the data off the page. Maybe next time he will learn to ask the right question better if he needs to login etc. He just asked how do you parse a table from a webpage. =) Quote Link to comment Share on other sites More sharing options...
richiec Posted July 5, 2007 Author Share Posted July 5, 2007 Thank you both for the help and thank you frost110 for the example. Just to clear something up, to get to the table i needed you do not need to be loged into the site. Once again, thank you. Rich. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.