SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow get html source from another site (was "I know its possibel, but I don't know how")

    Ok.. I posted this on a hacker type site and apparently they don't know because I only got 2 views... Then I posted it on a website devoted to php... I got 6 views and no replys. Then I posted on another forum, I got replys, but I didn't get anything helpful.

    Ok. From www.whatever.com/index.php how can I get the source for www.anothersite.com/page.php ? I don't want the php source. I just want what comes up when you right click and goto view source.

    I know its possible because I was just at 2 different sites that did it

    http://validator.w3.org/

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use file_get_contents() it is a PHP function.
    Kayzio - We don't hesitate, we accelerate.

  3. #3
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried it with http://www.site.com, http://site.com, www.site.com, and just site.com and all I get is a blank page.

  4. #4
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use CURL

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    theducktapeking, file_get_contents should work unless it has been disallowed by the server admin. What code are you using?

    Curl should also work but it's more than you really need and can take a bit of research to get familiar with it.
    Web Development Blog - Useful bits & pieces

  6. #6
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <?php
    $source = file_get_contents("http://www.whateverthesiteis.com/index.php");
    echo $source;
    ?>
    But I have tried it without the variable.

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    Welcome to the forums theducktapeking,
    you can use file_get_contents(), file(), cURL or fopen()

    file() is probably the easiest
    PHP Code:
    <?php
    // Get a file into an array.  In this example we'll go through HTTP to get
    // the HTML source of a URL.
    $lines file('http://www.example.com/');

    // Loop through our array, show HTML source as HTML source; and line numbers too.
    foreach ($lines as $line_num => $line) {
        echo 
    "Line #<b>{$line_num}</b> : " htmlspecialchars($line) . "<br />\n";
    }

    ?>
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That gets me a blank page too... And I have tried fopen(), and file_get_contents, and it says you have to install the libcurl package to use curl and its a free host so I can't.

    I'm going to make an account at a different hosting website, to see if its just my host.

  9. #9
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    file_get_contents will only work, if curl-wrappers have been enabled. Some shared hosts may disable it.

  10. #10
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,396
    Mentioned
    61 Post(s)
    Tagged
    0 Thread(s)
    What is the setting for allow_url_fopen on your server? Tell us what you get from:
    PHP Code:
    echo ini_get('allow_url_fopen'); 

  11. #11
    SitePoint Guru
    Join Date
    Sep 2004
    Posts
    613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    file_get_contents() works as long as the URL is exact, google.com wont' cut it. You have to input a .ext filename.

  12. #12
    SitePoint Zealot
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dude, just use fopen('http://www.anothersite.com/page.php', 'r'); and go through it using fgets(); Cake man.

    If your host doesn't allow it, switch.

  13. #13
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Salathe View Post
    What is the setting for allow_url_fopen on your server? Tell us what you get from:
    PHP Code:
    echo ini_get('allow_url_fopen'); 
    Its just a blank white page.

  14. #14
    SitePoint Guru
    Join Date
    Sep 2004
    Posts
    613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    file_get_contents uses less memory and is more efficient.

  15. #15
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Webnet View Post
    file_get_contents() works as long as the URL is exact, google.com wont' cut it. You have to input a .ext filename.
    The exact site I am trying (110%) is http://adbux.org/surf.php

  16. #16
    SitePoint Enthusiast Bellthorpe's Avatar
    Join Date
    Aug 2006
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by streety View Post
    Curl should also work but it's more than you really need and can take a bit of research to get familiar with it.
    I would hardly call the typing of 'man curl' to be 'research' ...
    Don't pay for webhosting features you don't need.
    Build your own webhosting plan.
    1,238 Unicode fonts for 75 written language groups.


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
  •