www.webdeveloper.com
Results 1 to 10 of 10

Thread: Imploding a website of stats

  1. #1
    Join Date
    Mar 2005
    Posts
    262

    Imploding a website of stats

    I'm trying to import a league table then strip out the useless stuff that I dont ie. page tags, and title tags etc. Then display it in a neat table, on my page.

    I'm using:

    PHP Code:
    <?php
        $test  
    implode ('',file("http://www.busa.org.uk/page.asp?section=0001000200010003"));
        
        print 
    $test;
    Which imports the page nicely, however I'm not sure how to get rid of the stuff that I dont need. Could I save it to a file, and then use regular expressions to search through and cut out the tags and info that I dont want. Is this possible, and if so is there a better way of doing this?

    Thanks and merry christmas

  2. #2
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    well before you do that, have you attempted to contact BUSA to see if they can provide you an XML export of their data?
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  3. #3
    Join Date
    Mar 2005
    Posts
    262

    Good idea, how would I do it with the implode though

    Thats a good idea, I will, how would I do it this way though using the implode in php. Just to satisfy my curiusity.

  4. #4
    Join Date
    Feb 2005
    Location
    BC, Canada
    Posts
    1,098
    I would attempt to use strip_tags to see if that removes most of the useless stuff (might cut text too :/). If not, you would need to determine where the data is located, and probably use an SGML parser to figure out what you want.
    Corn is no place for a mighty warrior!

  5. #5
    Join Date
    Jul 2005
    Location
    DF
    Posts
    174
    well if you just want to output de data here is a very simple script that allows you to do so.
    PHP Code:
    <?php
             $url 
    "http://www.busa.org.uk/page.asp?section=0001000200010003";
                 
    $ch curl_init("$url");
                 
    $fp fopen("escroto.txt""w");
                 
    curl_setopt($chCURLOPT_FILE$fp);
                 
    curl_setopt($chCURLOPT_HEADER0);
                 
    curl_exec($ch);
                 
    curl_close($ch);
                 
    fclose($fp);
                 
    $content file_get_contents("escroto.txt");
            
    $array1 = array();
            
    $array2 = array();

                    
    $array1 explode("<p></p>"$content);
                    
    $array2 explode("</tbody></table></p>"$array1[1]);

            echo 
    $array2[0] . "</tbody></table></p>";

    ?>

  6. #6
    Join Date
    Mar 2005
    Posts
    262
    thank you, but if I wanted to search through the arrays and to cut out the text like links, that i didnt want, could I use preg_matches to match the links and then delete them. Or is there a #nother way, as this might interfer with the data that im trying to import.

  7. #7
    Join Date
    Jul 2005
    Location
    DF
    Posts
    174
    Sorry, I don't understand, which links???
    could you explain yourself a little more???

  8. #8
    Join Date
    Mar 2005
    Posts
    262
    Sorry about that, all I want to display, is whats in the tables, ie. the league tables not the actual whole page which include the lnks etc.

  9. #9
    Join Date
    Mar 2005
    Posts
    262
    When I run the below code I seem to get this error: Fatal error: Call to undefined function: curl_init() in H:\xampp\htdocs\www\1uwafc\busa\index.php on line 26.

    What does this mean?

    Quote Originally Posted by Huevoos
    well if you just want to output de data here is a very simple script that allows you to do so.
    PHP Code:
    <?php
             $url 
    "http://www.busa.org.uk/page.asp?section=0001000200010003";
                 
    $ch curl_init("$url");
                 
    $fp fopen("escroto.txt""w");
                 
    curl_setopt($chCURLOPT_FILE$fp);
                 
    curl_setopt($chCURLOPT_HEADER0);
                 
    curl_exec($ch);
                 
    curl_close($ch);
                 
    fclose($fp);
                 
    $content file_get_contents("escroto.txt");
            
    $array1 = array();
            
    $array2 = array();

                    
    $array1 explode("<p></p>"$content);
                    
    $array2 explode("</tbody></table></p>"$array1[1]);

            echo 
    $array2[0] . "</tbody></table></p>";

    ?>

  10. #10
    Join Date
    Jul 2005
    Location
    DF
    Posts
    174
    Oh it means that you do not have the curl library, I believe it should work with the following changes

    PHP Code:
    <?php
             $url 
    "http://www.busa.org.uk/page.asp?section=0001000200010003";
    /*
                 $ch = curl_init("$url");
                 $fp = fopen("escroto.txt", "w");
                 curl_setopt($ch, CURLOPT_FILE, $fp);
                 curl_setopt($ch, CURLOPT_HEADER, 0);
                 curl_exec($ch);
                 curl_close($ch);
                 fclose($fp);
                 $content = file_get_contents("escroto.txt");
    */
                    
    $content implode('',file("http://www.busa.org.uk/page.asp?section=0001000200010003")); 
            
    $array1 = array();
            
    $array2 = array();

                    
    $array1 explode("<p></p>"$content);
                    
    $array2 explode("</tbody></table></p>"$array1[1]);

            echo 
    $array2[0] . "</tbody></table></p>";

    ?>
    It is suposed to print in your page only the table with the results
    Last edited by Huevoos; 12-27-2005 at 06:39 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles