TexasMd91 Posted September 26, 2007 Share Posted September 26, 2007 I am currently making a Halo 3 Player Image Generator ( http://deltadesigns.org/texasmd/generator/playerimage/ ) And I have been trying to find a way how they can insert the URL of some one's bungie.net profile (heres an example of a profile: http://www.bungie.net/Stats/Halo3/Default.aspx?player=sports209 ) and get their player image off that website that they enter, and then display what parts they are using and what colors. So I need to get whats between <div class="model" ><img id="ctl00_mainContent_imgModel" src=" and " style="border-width:0px;"/></div> How would I do this? Quote Link to comment https://forums.phpfreaks.com/topic/70703-getting-information-off-a-website/ Share on other sites More sharing options...
rarebit Posted September 26, 2007 Share Posted September 26, 2007 Have a play with these type's of functions... http://uk3.php.net/manual/en/function.ereg.php http://uk3.php.net/manual/en/function.preg-grep.php There's a whole forum here on the subject... http://www.phpfreaks.com/forums/index.php/board,43.0.html Quote Link to comment https://forums.phpfreaks.com/topic/70703-getting-information-off-a-website/#findComment-355705 Share on other sites More sharing options...
GingerRobot Posted September 26, 2007 Share Posted September 26, 2007 Indeed. You'll first need to get information from the website either with file_get_contents or with cURL (using file_get_contents() will be easier, unless specific headers need to be sent to the site). As rarebit mentioned, you'll then need to find the relevant information using regular expresions. Quote Link to comment https://forums.phpfreaks.com/topic/70703-getting-information-off-a-website/#findComment-355715 Share on other sites More sharing options...
HuggieBear Posted September 26, 2007 Share Posted September 26, 2007 As rarebit mentioned, you'll then need to find the relevant information using regular expresions. This should be very easy as the developers have used a separate div class for the display of the image... <div class="model"> Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70703-getting-information-off-a-website/#findComment-355729 Share on other sites More sharing options...
HuggieBear Posted September 26, 2007 Share Posted September 26, 2007 The following works... <?php // Set the URL $url = 'http://www.bungie.net/Stats/Halo3/Default.aspx?player=sports209'; // Get the entire page contents $page = file_get_contents($url); // Match the image source preg_match('/class="model".*?src="([^\"]+)/', $page, $matches); $image_source = $matches[1]; // Echo the source echo $image_source; ?> Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70703-getting-information-off-a-website/#findComment-355734 Share on other sites More sharing options...
TexasMd91 Posted September 27, 2007 Author Share Posted September 27, 2007 The following works... <?php // Set the URL $url = 'http://www.bungie.net/Stats/Halo3/Default.aspx?player=sports209'; // Get the entire page contents $page = file_get_contents($url); // Match the image source preg_match('/class="model".*?src="([^\"]+)/', $page, $matches); $image_source = $matches[1]; // Echo the source echo $image_source; ?> Regards Huggie Alright thanks, however what is with all the extra characters that are on the preg_match function line. Quote Link to comment https://forums.phpfreaks.com/topic/70703-getting-information-off-a-website/#findComment-356139 Share on other sites More sharing options...
HuggieBear Posted September 27, 2007 Share Posted September 27, 2007 Take a look at Regular Expression Syntax in the manual first, as there's a section that displays the meta-characters which may answer a lot of your questions. Regular Expression Syntax is really useful to know as it's excellent for writing search routines and is used in a lot of languages, there aren't many differences between language when it comes to RegEx's Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70703-getting-information-off-a-website/#findComment-356241 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.