Hi I want to get all the webpage contents in my website from another url. I have already tried get_file_contents() but there was the relative url problem. Also file open and some other functions were also have similar problem. Could any one give me how I can get all the webpage contents to my website with php code? Or how can I get rid of relative url not shown with get_file_contenst()? Thanks. H.
In the remote url...there is given url of image as (../images/tree.jpg)..then using file_get_contents will parse it as "www.mysite.com/images/tree.jpg" instead of "www.remoteurl/images/tree.jpg".That donot show the images when clicked. That is what I tried to say. But absolute url starting from "http://www.remoteurl.../.../" are alright there. Could you have any idea? thanks.
When I used the get_file_contents(), it worked well and gave the webpage as it is.But when I clicked to all the images, they were linked to my browser as "www.MYSITE.com/images" (suppose that MYSITE is my domain)...but it should be www.remotesite.com/images. The problem was , in the remote site the images was given relative url as (../images/1.jpg)...which has to be as remotesite/images/1.jpg inside my site.But inside my site,using file_get_contents() it is pointing to my site for the images to show which is wrong. I have get all the web contents using iframe but I want it to be with php. Do you have any idea? Thanks in advance
Just use $result=str_replace("../","http://www.domain.com",$TheTextSourceToReplace); Code (markup): It will work nicely for any relative links into the sub level. Basically you only have one "../" However, if you try to fetch pages that has a link to parent level pages it would be a different case (e.g. if you have "../../../") More info on php.net http://php.net/manual/en/function.str-replace.php p.s. if this helps you, please don't forget to add my reputation
Actually my parent level is "../../".Can you please give me the full code(also comments..) with file_get_contents()? Thanks.