Curl - Absolute Path Problem. Require Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maanav Jackson

    #1

    Curl - Absolute Path Problem. Require Help

    Hi

    I am displaying a third party webpage into a variable using curl
    library. When i am displaying the variable in the browser using echo
    command as shown below.

    echo $pagecopy;

    Browser is not displaying the page as it display when we visit the
    page directly in browser. Instead it references all the file path,
    css path, form action path to http://localhost/filenamepath OR CSS
    Path or FormAction Path instead of www.xyz.com/filepath (eg,
    http://www.xyz.com/books/1stGoodBook.html).

    So in the browser all the css, images is not displaying properly.
    since relative path is referenced to local host (http://localhost/)
    instead of website domain direct path (eg. http://otherwebsite.com/).

    How to rectify this problem so that it is referenced to absolute path
    instead of relative path and all the css, files, webpages works
    properly.

    Regards
    Maanav Jackson
    maanavjackson@g mail.com
  • Sjoerd

    #2
    Re: Curl - Absolute Path Problem. Require Help

    On Aug 9, 10:36 am, Maanav Jackson <maanavjack...@ gmail.comwrote:
    I am displaying a third party webpage into a variable using curl
    library.
    [...] it references all the  file path,
    css path, form action path tohttp://localhost/filenamepathOR CSS
    Path or FormAction Path instead ofwww.xyz.com/filepath
    Do you have permission from the third party to use his website?
    Otherwise it may be unethical, even illegal, to show his page on your
    site.

    Having said that, the problem is with the HTML. If the HTML references
    a file like so:
    <img src="foo.jpg" alt="Picture of a Foo" />
    Then the browser requests that file from the same server and the same
    directory as the referencing page. So if this page is at http://www.example..com/bar/,
    the image should be at http://www.example.com/bar/foo.jpg.

    No need for concern, all you need to do is rewrite all file
    references, such as those in image tags, or download all referenced
    files to your own server.

    Provided you have the approval of the site owner, off course.

    Comment

    Working...