Created
October 27, 2016 23:16
-
-
Save simon0191/06c5919cf95e672ac8162fc07e9ecc50 to your computer and use it in GitHub Desktop.
¿Cómo hacer que Esperanza Gomez gane los premios Shock?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://medium.com/@simon0191/c%C3%B3mo-hacer-que-esperanza-gomez-gane-los-premios-shock-8bb0044ec074 | |
require 'date' | |
require 'cgi' | |
require 'curb' | |
TOKEN_REGEX = /.*'(.*)'.*/ | |
def vote(account_id, poll_id, vote_id, site_url, user_agent) | |
timestamp = DateTime.now.strftime('%Q') | |
token_url = "https://polldaddy.com/n/#{account_id}/#{poll_id}?#{timestamp}" | |
c = Curl::Easy.new(token_url) do |curl| | |
curl.headers["User-Agent"] = user_agent | |
curl.headers["accept-language"] = "es,en;q=0.8" | |
curl.headers["accept"] = "*/*" | |
curl.headers["referer"] = site_url | |
curl.headers["authority"] = "polldaddy.com" | |
curl.verbose = true | |
end | |
c.perform | |
puts c.body_str | |
token = c.body_str.match(TOKEN_REGEX)[1] | |
vote_url = [ | |
"http://polls.polldaddy.com/vote-js.php", | |
"?p=#{poll_id}", | |
"&b=1", | |
"&a=#{vote_id},", | |
"&o=", | |
"&va=0", | |
"&cookie=0", | |
"&n=#{token}", | |
"&url=#{CGI::escape(site_url)}" | |
].join | |
c = Curl::Easy.new(vote_url) do |curl| | |
curl.headers["User-Agent"] = user_agent | |
curl.headers["accept-language"] = "es,en;q=0.8" | |
curl.headers["accept"] = "*/*" | |
curl.headers["referer"] = site_url | |
curl.headers["connection"] = "keep-alive" | |
curl.verbose = true | |
end | |
c.perform | |
body = c.body_str.force_encoding("UTF-8") | |
puts body | |
if body["¡GRACIAS!"] | |
puts "success" | |
elsif body["too many votes"] || body["You will be unblocked after a cooling off period"] | |
puts "blocked" | |
else | |
puts "error" | |
end | |
end | |
while true | |
sleep(1) | |
vote( | |
ENV['account_id'], | |
ENV['poll_id'], | |
ENV['vote_id'], | |
ENV['site_url'], | |
ENV['user_agent'] | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment