サーラリマンは働き過ぎ、社畜化に注意しよう!!

rapberry pi ruby

raspberry
スポンサーリンク

apt-get install rubygems

apt-get install ruby-nokogiri

apt-get install ruby–mechanize

実行

ruby test.rb

アマゾンの自分のページにログイン

vi amazon-login.rb

require ‘open-uri’
require ‘nokogiri’
require ‘mechanize’
require ‘csv’
require ‘kconv’
agent = Mechanize.new
agent.user_agent_alias = ‘Windows IE 7’
url = ‘https://www.amazon.co.jp/ap/signin?_encoding=UTF8&openid.assoc_handle=jpflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.co.jp%2Fgp%2Fyourstore%2Fhome%3Fie%3DUTF8%26ref_%3Dnav_signin’
page = agent.get(url)
login_form = page.forms_with(:name => ‘signIn’).first
login_form.fields_with(:name => ‘email’).first.value = “アカウントのメルアド”
login_form.fields_with(:name => ‘password’).first.value = “パスワード”
page2 = login_form.click_button
puts page2.title

 

raspberryruby
スポンサーリンク
シェアする
ふじやんをフォローする
なんでもDIY

コメント