[Wanted] Google news grabber (script) on PHP

Discussion in 'PHP' started by Koster, Nov 9, 2007.

  1. #1
    I am looking for php script, that gets last news from Google RSS channel (http://news.google.com/?output=rss).

    To get title, link and description - there is no problem. There problem is to parse description that have html tags. I need only simple title, descriptions, that describes the article, link to the image and link to the google page with this news article.

    Thanks!
     
    Koster, Nov 9, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Not sure if I understand your problem. What happens if a description has HTML? Doesn't it parse correctly? Do you want to remove it?

    If you want to remove the HTML from the description, you could do:
    
    $description = strip_tags(html_entity_decode($description));
    
    PHP:
     
    nico_swd, Nov 9, 2007 IP
  3. Koster

    Koster Guest

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Google returned this description:
    <table border=0 width= valign=top cellpadding=2 cellspacing=7><tr><td width=80 align=center valign=top><a  href="http://news.google.com/news/url?sa=T&ct=us/1i-0&fd=R&url=http://www.thebostonchannel.com/sports/14543862/detail.html&cid=1123206686&ei=xio0R_W6MZyG0gG1vPTRBQ"><img src=http://news.google.com/news?imgefp=zgNhZn2YoqcJ&imgurl=www.thebostonchannel.com/2007/1029/14444805_240X180.jpg width=80 height=60 alt="" border=1><br><font size=-2>Boston Channel.com</font></a></td><td valign=top class=j><br><div class=lh><a href="http://news.google.com/news/url?sa=T&ct=us/1-0&fd=R&url=http://www.chicagotribune.com/news/local/chi-dog_bite_09nov09,1,1515495.story&cid=1123206686&ei=xio0R_W6MZyG0gG1vPTRBQ">Father charged in <b>dog's</b> mutilation of infant son</a><br><font size=-1><font color=#6f6f6f>Chicago Tribune,&nbsp;United States&nbsp;-</font> <nobr>5 hours ago</nobr></font><br><font size=-1>Charges were filed against a  Lake Villa man Thursday after his girlfriend's <b>dog</b> seriously injured the man's 4-month-old son, authorities said. <b>...</b></font><br><font size=-1><a href="http://news.google.com/news/url?sa=T&ct=us/1-1&fd=R&url=http://www.chicagotribune.com/news/local/chi-dog_bite_bothnov06,0,657910.story%3Fcoll%3Dchi-technology-col&cid=1123206686&ei=xio0R_W6MZyG0gG1vPTRBQ"><b>Dog</b> mutilates sleeping infant in Waukegan</a> <font size=-1 color=#6f6f6f><nobr>Chicago Tribune</nobr></font></font><br><font class=p size=-1><a class=p href=http://news.google.com/?ie=ISO-8859-1&ncl=1123206686&hl=en><nobr>all 56 news articles</nobr></a></font></div></td></tr></table>
    PHP:
    I found some function, that parse this code:
    preg_match_all("|<td valign=top><a href=\"(.*)\" id=(.*)><b>(.*)</b></a><br><font size=-1><font color=\#6f6f6f><b>(.*)&nbsp;-</font> <nobr>(.*)</nobr></b></font><br><font size=-1>(.*)</font>|Ui",$google,$result);
    
    /*
    
    Output info:
    $result[0] - complete results, just junk, not always useable
    $result[1] - Array of news URL's
    $result[2] - Array of news id's (sed by google, best to ignore)
    $result[3] - Array of news headlines
    $result[4] - Array of news sources
    $result[5] - Array of posted times
    $result[6] - Array of news descriptions
    
    */
    PHP:
    But it is not work :(
     
    Koster, Nov 9, 2007 IP
  4. bilirkishi

    bilirkishi Well-Known Member

    Messages:
    213
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #4
    need update.
     
    bilirkishi, Dec 2, 2014 IP