1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Regex Help

Discussion in 'PHP' started by crazyryan, Oct 28, 2008.

  1. #1
    Some reason I always have a problem when it comes to regex/scraping. Not sure what I'm doing wrong.

    My code:

    <?php
    set_time_limit(0);
    
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, "http://steamcommunity.com/id/walesalex105/friends");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
    
    $file = curl_exec($ch);
    
    preg_match_all('            <div class="friendBlockIcon">
                    <div class="iconHolder_(.*+)"><div class="avatarIcon"><a href="(.*+)"><img src="(.+*)" \/><\/a><\/div><\/div>
                <\/div>
                <p><a class="linkFriend_(.*+)" href="(.*+)">(.*+)<\/a><br \/>
                <span class="friendSmallText">(.*+)<\/span><\/p>', $file, $matches);
    
    echo '<pre>';
    
    print_r($matches);
    
    curl_close($ch);
    
    ?>
    PHP:
    For some reason it's not picking up any data :confused:

    Anyone know why?

    Thanks
     
    crazyryan, Oct 28, 2008 IP