Need help Getting Information... from another website

Discussion in 'PHP' started by KingW, Jun 8, 2009.

  1. #1
    I would like to create a Script that pulls some Infomation from an Inputed URL, and Put the pulled Information into Text boxes.

    Here is the page with the Info I want
                <tr>
                    <td>Wanter1: Yes</td> //This will be Yes or No..
                </tr>
                <tr>
                    <td>Wanted2: 211</td>//This will be a 1-3Digit Number
                </tr>
                <tr>
                    <td>Notwanted: 354906</td>//This I want Ignored
                </tr>
                <tr>
                    <td>Wanted3: 243</td>//This will be a 1-3Digit Number
                </tr>
                <tr>
                    <td>Wanted4: 216</td>//This will be a 1-3Digit Number
                </tr>
                <tr>
                    <td>Wanted5: 142</td>//This will be a 1-3Digit Number
                </tr>
                <tr>
                    <td>Wanted6: 103</td>//This will be a 1-3Digit Number
                </tr>
                <tr>
                    <td>Wanted7: 111</td>//This will be a 1-3Digit Number
    </tr>
    
    HTML:
    Would there be anyways to pull that specific Information? I don't want the "Wanted1:" Part, Just the rest..

    If you can help me with this, But need more Infomation, Please PM me.
     
    KingW, Jun 8, 2009 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    Site Content are <b> <? print file_get_contents("http://www.apitalk.com"); ?> </b>
    HTML:
    I hope it helps
     
    Vooler, Jun 9, 2009 IP
  3. clarky_y2k3

    clarky_y2k3 Well-Known Member

    Messages:
    114
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    108
    #3
    What about something like this:-

    <?php
    // The URL of the page
    $sUrl = '';
    // Read the source code
    $sSource = file_get_contents($sUrl); 
    
    // Match the pattern "<td>...: ...</td>"
    preg_match_all('/<td>([^:]+):\s([^<]+)<\/td>/', $sSource, $aData);
    
    // Structure data 
    $aInfo = array();
    foreach($aData[1] as $iKey => $sKey)
    {
        $aInfo[$sKey] = $aData[2][$iKey];
    }
    
    // Output information extracted
    print_r($aInfo);
    
    /*
    Array
    (
        [Wanter1] => Yes
        [Wanted2] => 211
        [Notwanted] => 354906
        [Wanted3] => 243
        [Wanted4] => 216
        [Wanted5] => 142
        [Wanted6] => 103
        [Wanted7] => 111
    )
    */
    ?>
    PHP:
     
    clarky_y2k3, Jun 10, 2009 IP