class Commenter
Public Class Methods
postlink(url, keyword, comment, list)
click to toggle source
# File lib/blogcomments.rb, line 13 def self.postlink(url, keyword, comment, list) @url=url @keyword=keyword @comment=comment @list=list @list.each { |x| begin @singleurl=@url.unspin @singlekeyword=@keyword.unspin @singlecomment=@comment.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") comment_form=page.form_with("method"=>"POST") else comment_form=page.form.first end comment_form.author="#{@singlekeyword}" comment_form.email=Faker::Internet.email comment_form.url="#{@singleurl}" comment_form.comment="#{@singlecomment}" page = agent.submit(comment_form) puts "Posted to #{x}" rescue puts "Error posting to #{x}" end } end