RSS FEEDS

N

Newb Newb

Using Rss Parser I loaded Some Url's into the database.
All The Rss feeds has been stored in the table.
All The Rss Stories Has Been Stored In the Stories Table.
Stories Table Has Fields Like Story Name Story Description
Story Description Fields Contains Images Too...
That Story description must Not Contain Images
I want to restrict the images Not to be shown in the view.
Images has to be displayed separetely.Not Inside the Story Description
field.
I Extracted the Images and dispalyed separately using Hpricot.
But My Story Description Field Shows the Images. I don't Know How to
Restrict the Images To Be Shown..
Any Advices...


My COde Starts Here


require 'rss'
require 'open-uri'
require 'hpricot'

@feeds = Feed.find:)all)
@feeds.each do |f|
puts f.url
feed = RSS::parser.parse(f.url)


puts "== #{feed.channel.title} =="
puts "channel name: #{feed.channel.title}"
feed.items.each do |item|
puts "Title: #{item.title}"
puts "URL: #{item.link}"

puts "Description: #{item.description}"




@stories = Story.new
@stories.title = item.title
@stories.description = item.description
@stories.feed_id = item.id
@stories.guid = item.guid

doc = Hpricot.parse(item.description)
imgs = doc.search("//img")


@src_array = imgs.collect{|img|img.attributes["src"]}

@src_array = @src_array.to_s


@stories.picture = @src_array
@stories.save

end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top