Created
April 11, 2013 16:01
-
-
Save tommorris/5364658 to your computer and use it in GitHub Desktop.
code I use to sync my posts up with app.net versions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "nokogiri" | |
require "open-uri" | |
data = Nokogiri::XML(open("https://alpha-api.app.net/feed/rss/users/49269/posts")) | |
items = data.xpath("//item//atom:link/@href", "atom" => "http://www.w3.org/2005/Atom").map(&:to_s).map {|i| i.split("/").last.to_i }.zip(data.xpath("//item//link").map(&:text)) | |
items.each do |i| | |
p = Post.find(i[0]) | |
unless p.properties.has_key?('appdotnet') | |
p.properties['appdotnet'] = i[1] | |
p.save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment