SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    May 2002
    Location
    RI-USA
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can PHP download / view html source from another server?

    I was thinking of writing a link checker with php. But in order for that to happen php has to look at another server. So can PHP download / view html source from another server? I'm pretty sure the answer is no, but worth a shot

    Right now I'm using fread, is there another way to do it? Thanks for any help.

  2. #2
    SitePoint Addict shrikie's Avatar
    Join Date
    Dec 2002
    Location
    Hyperion
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DigitalBurn
    I was thinking of writing a link checker with php. But in order for that to happen php has to look at another server. So can PHP download / view html source from another server? I'm pretty sure the answer is no, but worth a shot

    Right now I'm using fread, is there another way to do it? Thanks for any help.
    that's called "screen scraping".. you can search on that

  3. #3
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    file() will grab a web page as an array of data, file_get_contents() if you have php 4.30 or above, will return a page as a string of data. Or you can use explode('', file('http://www.site.com') to return a string the former is faster. That will return it but you will still need to manipulate it to get what you want out of it.

  4. #4
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or you can use explode('', file('http://www.site.com') to return a string the former is faster.
    exlode is supposed to be implode.

  5. #5
    SitePoint Zealot
    Join Date
    May 2002
    Location
    RI-USA
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks all. Used file and works perfectly.

  6. #6
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Gaheris
    exlode is supposed to be implode.
    See what happens when I post before my morning coffee.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •