IDN Domains, IDN Domain Forums, Arabic Domains, Chinese Domains, Buy, Sell, and Appraise  

Go Back   IDN Domains, IDN Domain Forums, Arabic Domains, Chinese Domains, Buy, Sell, and Appraise > IDN Development > General Development
Home Chat Register FAQ Calendar Mark Forums Read

General Development General Development

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 8th May 2008, 14:31:47
alexd's Avatar
Premium Member
iTrader Rating: (2) - old IDNF ratings here
 
Join Date: Apr 2008
Posts: 170
Rep Power: 0
alexd is an unknown quantity at this point
Default RSS Parser - PHP Help ??

I have been looking to knock up a few more of my domains instead of parking them, and I remembered about a site I used to have a few years ago before selling it off to someone, which used an RSS parser / PHP script, that would pull content from Google news related to whatever keyword/s I wanted.

I thought I would try and use it for a few of my idns. However, I am having a few problems getting it to work in languages other than english.

There are two files used - index.php and rss.inc


Index.php ( Main page )

This contains the following code ...
<?php include("rss.inc"); ?>


------------
Rss.inc ( Script that pulls the content from Google News )
Code:
<?php

set_time_limit(0);

$file = "http://news.google.com/news?sourceid=navclient&ie=UTF-8&rls=GGLG,GGLG:2005-22,GGLG:en&q=KEYWORD-WILL-GO-IN-HERE&output=rss";

$rss_channel = array();
$currently_writing = "";
$main = "";
$item_counter = 0;

function startElement($parser, $name, $attrs) {
       global $rss_channel, $currently_writing, $main;
       switch($name) {
           case "RSS":
           case "RDF:RDF":
           case "ITEMS":
               $currently_writing = "";
               break;
           case "CHANNEL":
               $main = "CHANNEL";
               break;
           case "IMAGE":
               $main = "IMAGE";
               $rss_channel["IMAGE"] = array();
               break;
           case "ITEM":
               $main = "ITEMS";
               break;
           default:
               $currently_writing = $name;
               break;
       }
}

function endElement($parser, $name) {
       global $rss_channel, $currently_writing, $item_counter;
       $currently_writing = "";
       if ($name == "ITEM") {
           $item_counter++;
       }
}

function characterData($parser, $data) {
    global $rss_channel, $currently_writing, $main, $item_counter;
    if ($currently_writing != "") {
        switch($main) {
            case "CHANNEL":
                if (isset($rss_channel[$currently_writing])) {
                    $rss_channel[$currently_writing] .= $data;
                } else {
                    $rss_channel[$currently_writing] = $data;
                }
                break;
            case "IMAGE":
                if (isset($rss_channel[$main][$currently_writing])) {
                    $rss_channel[$main][$currently_writing] .= $data;
                } else {
                    $rss_channel[$main][$currently_writing] = $data;
                }
                break;
            case "ITEMS":
                if (isset($rss_channel[$main][$item_counter][$currently_writing])) {
                    $rss_channel[$main][$item_counter][$currently_writing] .= $data;
                } else {
                    $rss_channel[$main][$item_counter][$currently_writing] = $data;
                }
                break;
        }
    }
}

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r"))) {
    die("could not open XML input");
}

while ($data = fread($fp, 4096)) {
    if (!xml_parse($xml_parser, $data, feof($fp))) {
        die(sprintf("XML error: %s at line %d",
                    xml_error_string(xml_get_error_code($xml_parser)),
                    xml_get_current_line_number($xml_parser)));
    }
}
xml_parser_free($xml_parser);

// output HTML
// print ("<div class=\"channelname\">" . $rss_channel["TITLE"] . "</div>"); 

if (isset($rss_channel["ITEMS"])) {
    if (count($rss_channel["ITEMS"]) > 0) {
        for($i = 0;$i < count($rss_channel["ITEMS"]);$i++) {
            if (isset($rss_channel["ITEMS"][$i]["LINK"])) {
            print ("\n<div class=\"itemtitle\"><a href=\"" . "go.php?url=" . $rss_channel["ITEMS"][$i]["LINK"] . "\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</a></div>");
            } else {
            print ("\n<div class=\"itemtitle\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</div>");
            }
             print ("<div class=\"itemdescription\">" . $rss_channel["ITEMS"][$i]["DESCRIPTION"] . "</div><br />");         }
    } else {
        print ("<b>There are no articles in this feed.</b>");
    }
}

?>
For an English search term, it works fine - but whenever I try and use a foreign language search term - in my case, a Greek One, I am not getting anything working.

--
EDITED at member's request.
--

Has anyone got an suggestions as to what I might be doing wrong, or any similar scripts/solutions, that I can use to grab content from Google news.

Thanks for your time

Alex
__________________
"She thinks I'm a nice guy. Women always think I'm nice. But women don't want nice. Why is nice bad? What kind of a sick society are we living in when nice is bad?"
George Costanza

Last edited by mj : 8th May 2008 at 15:55:13.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiGoogle Bookmark this Post!Twit this!Yahoo Bookmark this Post!
Reply With Quote
  #2 (permalink)  
Old 8th May 2008, 14:53:05
mj's Avatar
mj mj is offline
Administrator
iTrader Rating: (3) - old IDNF ratings here
 
Join Date: Apr 2008
Posts: 1,271
Rep Power: 1
mj is on a distinguished road
Default

$keyword = "köln";
$encoded_keyword = urlencode($keyword);
$file = "http://news.google.com/news?sourceid=navclient&ie=UTF-8&rls=GGLG,GGLG:2005-22,GGLG:en&q=$encoded_keyword&output=rss";


.
__________________
"The meaning of life is to live a life of meaning."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiGoogle Bookmark this Post!Twit this!Yahoo Bookmark this Post!
Reply With Quote
  #3 (permalink)  
Old 8th May 2008, 15:11:52
alexd's Avatar
Premium Member
iTrader Rating: (2) - old IDNF ratings here
 
Join Date: Apr 2008
Posts: 170
Rep Power: 0
alexd is an unknown quantity at this point
Default

Mike

Thanks so much for that. I seems to be working great.

Alex
__________________
"She thinks I'm a nice guy. Women always think I'm nice. But women don't want nice. Why is nice bad? What kind of a sick society are we living in when nice is bad?"
George Costanza
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiGoogle Bookmark this Post!Twit this!Yahoo Bookmark this Post!
Reply With Quote
  #4 (permalink)  
Old 8th May 2008, 15:58:37
mj's Avatar
mj mj is offline
Administrator
iTrader Rating: (3) - old IDNF ratings here
 
Join Date: Apr 2008
Posts: 1,271
Rep Power: 1
mj is on a distinguished road
Default

Cool. Glad I could help.

.
__________________
"The meaning of life is to live a life of meaning."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiGoogle Bookmark this Post!Twit this!Yahoo Bookmark this Post!
Reply With Quote
  #5 (permalink)  
Old 24th May 2008, 05:59:16
Premium Member
iTrader Rating: (2) - old IDNF ratings here
 
Join Date: Apr 2008
Location: Shanghai
Posts: 53
Rep Power: 0
chineseidn is an unknown quantity at this point
Default

Great script and thx to the mod from mj it works fine for Chinese as well.

I did change the news source to google.cn.

Alexd, do you have sample sites where you use it which are revealable, I'm looking for ideas/inspiration on how to incorporate it.
__________________
علی.com/net | φαρμακα.com | комментарии.com | סקסי.com | 封筒.com | 不知道.com
and many more
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiGoogle Bookmark this Post!Twit this!Yahoo Bookmark this Post!
Reply With Quote
  #6 (permalink)  
Old 24th May 2008, 08:32:27
BurnsInternet's Avatar
Premium Member
iTrader Rating: (1) - old IDNF ratings here
 
Join Date: Apr 2008
Location: Atlanta
Posts: 140
Rep Power: 0
BurnsInternet is an unknown quantity at this point
Default

Do search engines seem to care either way? Are you caching the information so it can be indexed? Is caching 'allowed' or 'penalized' in any way?

My RSS feed seemed to have trouble running when IE7 came out. I put that on the backburner, but you have renewed my interest.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiGoogle Bookmark this Post!Twit this!Yahoo Bookmark this Post!
Reply With Quote
  #7 (permalink)  
Old 24th May 2008, 20:36:27
Member
iTrader Rating: (5) - old IDNF ratings here
 
Join Date: Apr 2008
Posts: 229
Rep Power: 0
Lidador is an unknown quantity at this point
Default

I am going to release this one to everyone very soon:

Keyword based + multiple feeds (compatible with 99% of the feeds) + ebay (keyword based also) + full utf-8 compatible.

PM for demo.

Last edited by Lidador : 24th May 2008 at 20:37:51.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiGoogle Bookmark this Post!Twit this!Yahoo Bookmark this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT +1. The time now is 06:50:30.


Powered by vBulletin®
All content is licensed as "Creative Commons"

Search Engine Friendly URLs by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68