danago Posted June 30, 2009 Share Posted June 30, 2009 Hi everyone. Just signed up Anyway, i have some basic knowledge of php; i am able to create basic working scripts etc., but nothing too extensive. Im thinking about starting a project, but before doing so, id like to extract some information from a database that is publically available from a certain website, so that i can re-organize the data into a way that will be most useful to me. The data i extract will not be for commercial use, so the method does not necessarily need to be the most efficient method. Is anybody able to suggest a function or class that i should perhaps look into that can do this type of thing? Thanks in advance. Sorry if i have not explained myself clearly enough. Dan. Quote Link to comment https://forums.phpfreaks.com/topic/164212-solved-extracting-data-from-external-website/ Share on other sites More sharing options...
patrickmvi Posted June 30, 2009 Share Posted June 30, 2009 You should use the PHP's CURL functions (provided that you have CURL set up) to retrieve the information you're looking for. Then use preg_match or preg_match_all to extract the information from the retrieved pages. Here are some links for this: CURL - http://www.php.net/curl preg_match - http://www.php.net/preg_match Quote Link to comment https://forums.phpfreaks.com/topic/164212-solved-extracting-data-from-external-website/#findComment-866285 Share on other sites More sharing options...
severndigital Posted June 30, 2009 Share Posted June 30, 2009 another good place to start be would be with the question ... what kind of database is it? or is it just web pages with information on it? if the latter is true .. you will really need to learn how to use preg_match very well. Even then, it might not be possible to get everything out exactly the way you want it. Quote Link to comment https://forums.phpfreaks.com/topic/164212-solved-extracting-data-from-external-website/#findComment-866288 Share on other sites More sharing options...
nadeemshafi9 Posted June 30, 2009 Share Posted June 30, 2009 used in conjunction with the above if its a JSOn or XML file or HTML or any text <?php $handle = fopen("http://www.example.com/", "rb"); $contents = ''; while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle); ?> Quote Link to comment https://forums.phpfreaks.com/topic/164212-solved-extracting-data-from-external-website/#findComment-866291 Share on other sites More sharing options...
danago Posted July 1, 2009 Author Share Posted July 1, 2009 Thanks for the help guys. To answer your question severndigital, it is just a website displaying the information. I managed to write up a script that does exactly what i need. The regular expressions for the preg match all function werent too hard to write since the extractions were fairly easy to do Thanks again, Dan. Quote Link to comment https://forums.phpfreaks.com/topic/164212-solved-extracting-data-from-external-website/#findComment-867052 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.