If you're using bloglines
(online feed reader) will probably keep the posts you find interesting using the "keep new".
After using the feed reader for a while, the number of interesting posts I have saved so important. I I thought there would be no fun to lose this data, so I made a script that makes a backup of these posts in an xml file. mechanize and hpricot
. Mechanize can browse web using simple commands as you see in the script. Hpricot can parse HTML and XML documents very easy and intuitive.
To use the script you need to install the following libraries:
gem install json gem install hpricot gem install
ActiveSupport gem install mechanize
And here is the script, I think is understood quite well what he does. I hope that well help you make a backup of your bloglines account (remember to change the EMAIL and PASSWORD values) or to learn a bit of work mechanize and hpricot.
require "rubygems" require "hpricot" require "json"
require "mechanize"
require "active_support"
bloglines # Reads a tree structure javascript
# That has all data feeds. Def
read_tree (tree_base, label = "")
tree_base.each do end
# Add more memory to hpricot otherwise couldn't load some webs.
Hpricot.buffer_size = 262144
agent = WWW::Mechanize.new
page = agent.get 'http://www.bloglines.com/login'
form = page.forms[1]
form.email = 'EMAIL'
form.password = 'PASSWORD'
<< [tree["n"], label, tree["kn"], "http://www.bloglines.com/myblogs_display?sub=#{tree["id"]}&site=#{tree["sid"]}"]
page = agent.submit form
# Get the bloglines sindicated feeds
menu_page = agent.get "http://www.bloglines.com/myblogs_subs"
start_text = "var initTreeData = "
end_text = "\n;\n"
js_feeds_tree_str = menu_page.content[menu_page.content.index(start_text)+start_text.size..menu_page.content.index(end_text)]
feeds_tree = JSON.parse js_feeds_tree_str.gsub("\\","")
@feeds = []
read_tree(feeds_tree["kids"])
puts "<bloglines_saves>"
@feeds.each do Index sqlite and development libraries:
sudo apt-get install sqlite3 libsqlite3-dev
Installing sqlite3-ruby interface to connect to sqlite3 database from Ruby.
sudo gem install sqlite3-ruby
(
If multiple versions to choose from, selecting the latest version
ruby.
)
Create the database, we really only an empty file that is all you need sqlite3.
database_name_dev.db
touch touch touch database_name_test.db
database_name_prod.db
Set
Ruby on Rails application to use these databases. Edit the file config / database.yml:
- development: adapter : sqlite3 database: db / database_name_dev.db
- test: adapter: sqlite3 database: db / database_name_test.db
-
Ready! from here you can develop your Rails application using sqlite3 as database.
0 comments:
Post a Comment