Prev | Current Page 303 | Next

David Berube

"Practical Reporting with Ruby and Rails"

title=feed_story.title.gsub(/<[^>]*>/, '') # strip HTML
new_story.guid=feed_story.guid
new_story.sourcename=feed_story.publisher.name if feed_story.publisher.name
new_story.url=feed_story.link
new_story.published_at = feed_story.published
new_story.save
end
else
# do nothing
end
end
end
Save this script as rss_loader.rb.
You can run this script as follows:
ruby rss_loader.rb Microsoft
processing story 'Microsoft Exchange Troubleshooting Assistant v1.1 (MSI)
- ZDNet' - new
processing story 'Being MVP and posting Microsoft copyrighted material without
.. - ZDNet UK' - new
. . .
nNote You may get errors about require_gem being obsolete, but the script should still run fine.
Now, if you run the script again, it will detect that the feed was recently loaded and is
in the cache, so it will exit:
ruby rss_loader.rb Microsoft
CHAPTER 11 n TRACKING THE NEWS WITH GOOGLE NEWS 220
feed is cached...
last retrieved: Sun Sep 02 18:55:12 UTC 2007
expires: Sun Sep 02 19:55:12 UTC 2007
Not all reporting requires a script.


Pages:
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
hotele Meck filmy w sieci Paul McCartney MC Hammer