[ruby] http client parser
標題[ruby] http client parser
時間北極光 (2010/05/26 Wed 11:45:45)
id="xxx"
pwd="yyy"
require 'httpclient'
clnt = HTTPClient.new
clnt.set_cookie_store('cookie.dat')
clnt.get_content("https://xxxxx.com/login/")
body = { 'email' => id, 'password' => pwd ,"rememberme" =>"no" , "referrer" => ""}
#登入行為
clnt.post("https://xxxxxxxx.com/login/", body)
res = clnt.get_content("http://xxxxxxx.com/the_target_url")
#字串分析
puts res.scan(/class="xxxx">(.*?)<\/td>/m)
其實還蠻輕鬆愉快的
比起 java httpclient的話,缺點就是要裝 ruby gem .
--
▄▅▆▇███▇▆▅▄▃ ╰┼╯─╮ ╮
◥███████████◣ ╰┼╯=│=│
◥██████───────◣ *. ╯ ╯ ╯ の 物 語 .*
◥███████──────◣ ~ ◢◣ ◢◣
◥██████───────◤ ◥◤* 空白的世界.翼 *◥◤
◥██▁▂▃▄▅▆▇███▆▅▄▃▂▂~telnet://tony1223.no-ip.info
--
╭═ Origin ─═ 北極光 aurora.twbbs.org κλμ ─╣
╚─ Author ═─ 114-34-160-41.HINET-IP.hi
Comments
No approved comments yet.