13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/blogcomments.rb', line 13
def self.postlink(url, keyword, , list)
@url=url
@keyword=keyword
=
@list=list
@list.each { |x|
begin
@singleurl=@url.unspin
@singlekeyword=@keyword.unspin
=.unspin
agent=Mechanize.new
agent.log=Logger.new(STDOUT)
agent.user_agent_alias = 'Windows Mozilla'
agent.open_timeout=8
agent.read_timeout=30
agent.max_history=1
page=agent.get("#{x}")
if page.form_with("method"=>"POST")
=page.form_with("method"=>"POST")
else
=page.form.first
end
.author="#{@singlekeyword}"
.email=Faker::Internet.email
.url="#{@singleurl}"
.="#{@singlecomment}"
page = agent.submit()
puts "Posted to #{x}"
rescue
puts "Error posting to #{x}"
end
}
end
|