0

I have ordered yahoo news rss, I use simplepie to separate the news items like title, content, url, date... and then insert them into database. I catch the source every 2 hours with cron. How to judge RSS source, if there has new then UPDATE into database?

I mean if the rss source has 10 items, 5 are old, 5 are new, I want just update the 5 items new and ignore the 5 old items. I do not want insert the repeart items.
And I want to get `echo` a list of the 5 new items.

This is my insert code.

mysql_select_db("rss",$db1);
mysql_query("INSERT INTO yahoonews (link, title, date, content, image, imagelink) VALUES ('".$link."', '".$title."', '".$date."', '".$content."', '".$image."', '".$imagelink."')");
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by mschroeder
0

Create hashes for the common fields that change. I'm thinking the title and content/body of each article. Store these two hashes with each item in your database.

When you process the feed again, generate the same hashes and look for any records where both hashes match. If you find a result disregard the item from the rss feed as it is identical to one in the database already.

When you find a mismatched title or body hash, update whichever of the fields does not match with the changes.

When you find no match on the title or body hash, insert the new item into your database.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.