What is RSS?
Abbreviation for Rich Site Summary, which means a rich site summary.
The main feature is
--Use RDF to convert content information into metadata. --Write the information in XML language.
Website elements | Markup language |
---|---|
Web page | HTML |
RSS | XML |
Gemfile
gem 'feedjira'
gem 'httparty'
$ bundle install
This time, I will write the server side processing, so I will look at the second and third coding.
python
rss = Feed.new(url: params[:url])
xml = HTTParty.get(rss).body
python
obj = Feedjira.parse(xml)
python
list = []
obj.entries.each do |item|
list += [
:title => item.title,
:url => item.url,
:title => item.summary,
:published => item.published.to_time.strftime("%Y-%m-%d %H:%M:%S")
]
end
You can get the content of the article by making the data an element of the array. ʻObj.entries` is a block of article content of an object.
python
data = {
feed: {
id: rss.id,
url: rss.url,
title: obj.title,
item: list
}
}
render :json => data
Return to the client in JSON format.
Recommended Posts