對抗垃圾信!請您點這裡:

我的E-mail:
我的Skype:My status

2007年2月25日

HEMiDEMi文章產生器 -- Ver. 0.1

原始碼在這邊:

require 'rubygems'
require 'mechanize'

class HEMiDEMi
def initialize(username="", password="")
agent = WWW::Mechanize.new
f = agent.get("http://www.hemidemi.com/member/signin_form").forms[1]
f["member[username]"], f["member[password]"] = username, password
f.submit
@agent = agent
@base_url = "http://www.hemidemi.com"
@new_path = "/user_bookmark/new"
end

def add(qs)
f = @agent.get(@base_url+@new_path).forms[1]
qs.each do |k, v|
f["user_bookmark[#{k}]"] = v
end
f.submit
end

end
=begin
qs = {
"title" => title,
"url" => url,
"quotes" => quotes,
"description" => desc,
"tag_string" => t_s,
"group_string" => g_s,
"embed" => embed
}
=end

qs = {
"title" => "G00g13",
"url" => "google.com"
}

hemidemi = HEMiDEMi.new("", "").add(qs)

目前這個版本只是雛型.. 還不能夠用來大量新增!
簡單介紹一下...

qs = {
"title" => title,
"url" => url,
"quotes" => quotes,
"description" => desc,
"tag_string" => t_s,
"group_string" => g_s,
"embed" => embed
}

qs是一個Hash,我只講其中幾個
quotes:代表的是"引述"
description:代表的是"說明"
embed:代表的是影片代碼

沒有留言: