lynxus Posted August 6, 2009 Share Posted August 6, 2009 Hi guys. how can i do this: a script runs ( i want it to call another script but wont wait for it to complete , IE: it will call getdata.php but will carry on and end like it would, Leaving getdata.php to run by itself. ) i want to be able to get getdata.php to load http://www.ip-db.com/212.125.94.168 and then get the Location information and put them in vars. so something like: somescript.php <?php call getdata.php?ip=212.125.94.168; echo "now doing the rest of this script and end without waiting for getdata.php ?> getdata.php <?php $ip = $_GET['ip']; get some vars from http://www.ip-db.com/$ip $city = ( the city bit of the page ); $country = ( the country bit ); ?> Any ideas will great? Thanks Graham Link to comment https://forums.phpfreaks.com/topic/169073-get-data-from-a-webpage/ Share on other sites More sharing options...
Bjom Posted August 6, 2009 Share Posted August 6, 2009 you want to multithread your php script? not possible without custom tailored hacks. just include the script and wait for it to finish, then go on. Does getdata really take so long as to necessitate this approach? Link to comment https://forums.phpfreaks.com/topic/169073-get-data-from-a-webpage/#findComment-892049 Share on other sites More sharing options...
Mardoxx Posted August 6, 2009 Share Posted August 6, 2009 <?php function getipdata($theip) { return file_get_contents("http://www.ip-db.com/$theip"); } function get_it($content, $what) { if($what == "city") { //funky regex here to get city return $city; } elseif ($what == "country") { //funky regex here to get country return $city; } } $data = getipdata(212.125.94.168); echo "CITY:".get_it($data, "city"); echo "COUNTRY:".get_it($data, "country"); this way it only gets the data once... I mean I'm crap w/ regex so that's how I'd do it.. one could if they were good, setup one HUGE expression to get all the data... then set it as an array Link to comment https://forums.phpfreaks.com/topic/169073-get-data-from-a-webpage/#findComment-892051 Share on other sites More sharing options...
lynxus Posted August 6, 2009 Author Share Posted August 6, 2009 I dont mind waiting, however i want to minimise the runtime of the main script ( if the external site is off ) it will cause the other script to wait . but yeh i dont mind waiting. If its a case of waiting then all the code can be in the one script insted of an external script. eitherway I still have no clue how to get the data from the webpage itself and put it into vars for me to use. Any ideas? thanks G Link to comment https://forums.phpfreaks.com/topic/169073-get-data-from-a-webpage/#findComment-892053 Share on other sites More sharing options...
Mardoxx Posted August 6, 2009 Share Posted August 6, 2009 http://webforumz.com/php/12595-multithreaded-php.htm Link to comment https://forums.phpfreaks.com/topic/169073-get-data-from-a-webpage/#findComment-892054 Share on other sites More sharing options...
lynxus Posted August 6, 2009 Author Share Posted August 6, 2009 <?php function getipdata($theip) { return file_get_contents("http://www.ip-db.com/$theip"); } function get_it($content, $what) { if($what == "city") { //funky regex here to get city return $city; } elseif ($what == "country") { //funky regex here to get country return $city; } } $data = getipdata(212.125.94.168); echo "CITY:".get_it($data, "city"); echo "COUNTRY:".get_it($data, "country"); this way it only gets the data once... I mean I'm crap w/ regex so that's how I'd do it.. one could if they were good, setup one HUGE expression to get all the data... then set it as an array yeah thats sorta what im looking for. However im also useless at regex( ive tried and failed oh so many times lol ) If anyone else has any input to the above that would be awesome! in the source of that page id like it to look at : <b>City:</b></font></td><td width="10"> </td><td><font face="arial" size="2">Cheltenham</td> It then can see that City : = cheltenham? thanks G Link to comment https://forums.phpfreaks.com/topic/169073-get-data-from-a-webpage/#findComment-892056 Share on other sites More sharing options...
Mardoxx Posted August 6, 2009 Share Posted August 6, 2009 well you need to match the string <b>City:</b></font></td><td width="10"> </td><td><font face="arial" size="2"> then capture any upper/lowercase letters of any length then match the string </td> how you do that... IDK! Link to comment https://forums.phpfreaks.com/topic/169073-get-data-from-a-webpage/#findComment-892245 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.