DaGeek247 Posted February 3, 2012 Share Posted February 3, 2012 Alrighty, I have posted about this before, but for a very different question. So different, i figured it merited a different post. anyways... I have a php script that downloads a webpages html code, then shows that code as its own on another server. I got it to work great, but it does not download/show the images and css. Using <base href> works great for the links, but the images are an issue, along with the css. Here's what I have got so far: (any scripts or other stuff is greatly appreciated) <?php //download the webpage $contents = file_get_contents($url); //we have downloaded the html from the page, //but not the external files such as css, and images //so now we add the images and css //start by splitting it into an easy to manage array $contentchunks = explode("/n", $contents); //mess with the html we downloaded foreach($contentchunks as $varname => $varval){ //varval is the single line of html //go through every line of the html code and replace it to my heart's content if(stristr($varval, 'src=') === TRUE) { //check to see if has what im looking for //get the url to download //download and insert the image } } //put the modified array back together $contents = implode("/n", $contentchunks); //view the webpage echo $contents; ?> I have a demonstration of what it does over at http://dageek247.tk/viewit/ Link to comment https://forums.phpfreaks.com/topic/256352-downloading-content-from-url-in-array/ Share on other sites More sharing options...
Andy-H Posted February 3, 2012 Share Posted February 3, 2012 http://www.google.co.uk/#sclient=psy-ab&hl=en&source=hp&q=PHP+proxy+server+tutorial&pbx=1&oq=PHP+proxy+server+tutorial&aq=f&aqi=g-v1&aql=&gs_sm=e&gs_upl=984l8453l0l8748l25l15l0l10l10l1l907l6319l0.2.5.3.0.1.4l24l0&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=a310b06952cec5c5&biw=1440&bih=775 Link to comment https://forums.phpfreaks.com/topic/256352-downloading-content-from-url-in-array/#findComment-1314238 Share on other sites More sharing options...
DaGeek247 Posted February 4, 2012 Author Share Posted February 4, 2012 Andy-H, im not sure if your link was sarcastic, or serious. either way, I had no idea what i was doing had been done before, so thanks. I think i got it now. im using my own modified version of http://www.doncaprio.com/2011/01/how-to-create-free-php-proxy-site.html And its working a lot better than what i ever thought i could acheive with my resources / knowledge. *solved* Link to comment https://forums.phpfreaks.com/topic/256352-downloading-content-from-url-in-array/#findComment-1314449 Share on other sites More sharing options...
Andy-H Posted February 4, 2012 Share Posted February 4, 2012 Nope, I wasn't being sarcastic, and I had a feeling that you didn't. Link to comment https://forums.phpfreaks.com/topic/256352-downloading-content-from-url-in-array/#findComment-1314457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.