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.

Preg Match problem (file get content)

Discussion in 'PHP' started by eruseldarine, Jul 14, 2008.

  1. #1
    i was using google search results but suddenly they changed something and now i can not.

    <?php
    header('Content-type:text/html; charset=utf-8');
    $s = file_get_contents("http://www.google.com.tr/search?hl=tr&q=test&meta=");
    preg_match("/<div class=g>(.*?)<h2 class=r>/Us",$s,$d);
    echo "<pre>";print_r($d);
    ?> 
    PHP:
    can you please tell me what is wrong
     
    eruseldarine, Jul 14, 2008 IP
  2. Mozzart

    Mozzart Peon

    Messages:
    189
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It works for me in my localhost... maybe the banned your server or something?
     
    Mozzart, Jul 14, 2008 IP
  3. eruseldarine

    eruseldarine Active Member

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #3
    no i tried in 3 servers :S did you see the google results ?
     
    eruseldarine, Jul 14, 2008 IP
  4. Mozzart

    Mozzart Peon

    Messages:
    189
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yep I did,

    I forgot try this in your 3 hosts
    
    <?php
    error_reporting(E_ALL);
    header('Content-type:text/html; charset=utf-8');
    $s = file_get_contents("http://www.google.com.tr/search?hl=tr&q=test&meta=");
    preg_match("/<div class=g>(.*?)<h2 class=r>/Us",$s,$d);
    echo "<pre>";print_r($d);
    ?>
    PHP:
     
    Mozzart, Jul 14, 2008 IP