Getting exact text from url using CURL ?

Discussion in 'PHP' started by electronic music, Sep 29, 2011.

  1. #1
    Hello...

    ...I'm trying to get exact text from external url ...

    Example http://89.248.173.11:8128/ (SHOUTCAST Page)

    ...and then to take only the name of the "Current Song:"

    ...Any help appreciated !!!
     
    electronic music, Sep 29, 2011 IP
  2. gvre

    gvre Member

    Messages:
    35
    Likes Received:
    6
    Best Answers:
    3
    Trophy Points:
    33
    #2
    You should grab page's content (with file_get_contents or curl) and then use the following regular expression to get the song title.
    $pattern = '#<td[^>]+>.+?Current Song.+?</td><td>.+?<b>([^<]+)</b></td>#si';
    PHP:
    tip: Add user agent header to file_get_contents.
     
    gvre, Sep 29, 2011 IP
    Raj Kumar likes this.
  3. SheetalCreation

    SheetalCreation Peon

    Messages:
    42
    Likes Received:
    1
    Best Answers:
    3
    Trophy Points:
    0
    #3
    curl for that url and get the content in a variable then extract your interest part from that.

    see php manual for curl.
     
    SheetalCreation, Sep 29, 2011 IP