Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is this possible

    Ive been reading several clan websites where players are able to retrieve the source code and parse it to get information from a website. For example say i wanted to get the value of "Total Members" from this site: http://www.battle.net/war3/ladder/w3...th&ClanTag=FNS

    Is it possible for me to retrieve the source code of this site and use regular expressions to get the number 27

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Absolutely! I did that to download over 4000 fonts from one site a while back! So much easier than downloading individual files

    The basic concept would be...

    1) open a file handle and read in the html from the page
    2) Parse the page using regular expressions
    3) use the data in your site.

    NOTE!!! If you're going to incorporate the content in your site, make SURE you GET PERMISSION to do this from the other site first!

  • #3
    New Coder
    Join Date
    May 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cool thanks. every clan has been doing it without problem so im guessing i would be allowed. Is there an example of a file handle being used. I don't expect people to do the code for me but just need an example of how to use a file handle for a web page.

  • #4
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Something like this should work...

    PHP Code:
    <?php
    ###################################
    ## CONFIGURATION                 ##
    ###################################
    ini_set("max_execution_time","300"); //script timeout in seconds
    ###################################
    ## END CONFIGURATION OPTIONS     ##
    ###################################
    function getFile($url) {
        
    $fh fopen($url,"r");
        
    $d="";
        while(
    $data fgets($fh)) {
            
    $d.=$data;
        }
        return 
    $d;
    }

    print 
    "<pre>".htmlentities(getFile("http://www.mysite.com/index.html"))."</pre>";
    ?>


  •  

    Posting Permissions

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