ishboo Posted June 23, 2007 Share Posted June 23, 2007 I'm trying to write this php application that retrieves information from another website that does not have a developer API or anyhting of the sort, they gave me permission to make my own stuff so I won't be angering them by overloading the server, thought to clear that up before anyone said anyhting. I am trying to get a string of information that is alway on a page in a <span id="co">string I want</span>. What would be the best way to do this? If there is no function designed for this(I'm pretty sure there isn't) then maybe I could get the source of the page and then just find the span tags I want with a simple function there. If I did that, how should I get the source of the web page? I'm am also open to any other suggestions and thanks in advance. Quote Link to comment Share on other sites More sharing options...
Rojay Posted June 23, 2007 Share Posted June 23, 2007 start with this http://www.php.net/file_get_contents AND http://www.php.net/manual/en/function.explode.php Quote Link to comment Share on other sites More sharing options...
ishboo Posted June 23, 2007 Author Share Posted June 23, 2007 Thank you very much, I knew it was on the tip of my toung. Quote Link to comment Share on other sites More sharing options...
corbin Posted June 23, 2007 Share Posted June 23, 2007 I would suggest regular expressions, but if it's just plain span tags then explode would be fine, or if you don't feel like messing with regular expressions, then explode would be fine too. A regular expression example with $content being the target pages content: $pattern = "/<span(.*?)>(.*?)</span>/"; if(preg_match($pattern, $content, $matches)) { echo $matches[1]; //the stuff in the span tags } Note: I'm not a regexp expert, infact I often forget syntaxes and modifiers, so that may or may not work haha. Quote Link to comment Share on other sites More sharing options...
mkoga Posted June 24, 2007 Share Posted June 24, 2007 I saw this on ajaxian. It could be interesting to try. It's called phpQuery which is a php port of jQuery. It looks like you should be able to select elements by css selectors and return them as a php object. Here's the link to the project: http://wiadomosc.info/plainTemplate/ If anyone tries this out, let me know what you think. 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.