Created
October 3, 2012 22:02
-
-
Save syohex/3830177 to your computer and use it in GitHub Desktop.
DMM API with Ruby nokogori
This file contains hidden or 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
#!/usr/bin/env ruby | |
# -*- coding:utf-8 -*- | |
require 'nokogiri' | |
require 'open-uri' | |
require 'pit' | |
config = Pit.get("dmm.co.jp", :require => { | |
"api_id" => "you email in twitter", | |
"affiliate_id" => "your password in twitter" | |
}); | |
url = %Q(http://affiliate-api.dmm.com/?api_id=#{config['api_id']}&affiliate_id=#{config['affiliate_id']}&operation=ItemList&version=1.00×tamp=2012-01-13%2014%3A08%3A16&site=DMM.co.jp&service=digital&keyword=maika) | |
xml = Nokogiri::XML(open(url).read) | |
item_nodes = xml.xpath('//item') | |
item_nodes.each do |item| | |
puts "Title:" + item.xpath('title').text | |
puts "Image:" + item.xpath('imageURL/large').text | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment