ruby honeybitcoin bot


SUBMITTED BY: Guest

DATE: Sept. 29, 2014, 5:42 p.m.

FORMAT: Text only

SIZE: 4.0 kB

HITS: 2036

  1. #!/usr/bin/env ruby
  2. # encoding: UTF-8
  3. require 'net/http'
  4. require 'uri'
  5. require 'open-uri'
  6. require 'fileutils'
  7. require 'nokogiri'
  8. require 'selenium/webdriver'
  9. require 'watir-webdriver'
  10. module HoneyCoin
  11. class HoneyCoinHarvester
  12. START_URL = 'http://www.honeybitcoin.com/'
  13. GOTO_URL = 'http://www.honeybitcoin.com/index.php?lang=en'
  14. =begin rdoc
  15. Public method returning random number between limits
  16. =end
  17. def aleat
  18. r = Random.new
  19. return r.rand(300..315)
  20. end
  21. =begin rdoc
  22. Public method checking if instance is on the true page
  23. =end
  24. def check_page
  25. @b.goto START_URL
  26. if
  27. @b.title == "Honey Bitcoin"
  28. then
  29. return true
  30. else
  31. return false
  32. end
  33. end
  34. =begin rdoc
  35. In order to create a valid uploader instance pass credentials of some registered account.
  36. =end
  37. def initialize(data)
  38. @proxy = data
  39. make_agent(@proxy)
  40. end
  41. def finalize
  42. kill_agent
  43. end
  44. =begin rdoc
  45. Logs into the site using address passed to constructor.
  46. Returns true value on success and false value if login failed.
  47. =end
  48. def login(addr)
  49. @addr = addr
  50. attempt = 0
  51. begin
  52. @b.goto START_URL
  53. sleep(10)
  54. @b.text_field(:id, "visitorADDRESS").when_present.set(@addr)
  55. @b.execute_script("ajax_newVisitor();")
  56. rescue
  57. attempt += 1
  58. retry unless attempt > 2
  59. raise "proxy unable to connect"
  60. end
  61. end
  62. =begin rdoc
  63. wait until next_button is present. click when present
  64. =end
  65. def wait_next
  66. @b.execute_script("check_VALID_URL_VISIT();")
  67. sleep(10)
  68. end
  69. =begin rdoc
  70. unless legal limit, process.
  71. =end
  72. def check_visit?
  73. if
  74. @b.text.include?("Has llegado a tu cupo por hoy, vuelve dentro de 24H por")
  75. then
  76. raise "24h limit over"
  77. elsif
  78. @b.text.include?("De momento no hay ninguna URL para visitar, pasate")
  79. then
  80. raise "no more urls to visit"
  81. elsif
  82. @b.text.include?("Internal Server Error")
  83. then
  84. raise "internal server error"
  85. elsif
  86. @b.text.include?("The server encountered an internal error or misconfiguration and was unable to complete your request.")
  87. then
  88. raise "internal server error"
  89. else
  90. return true
  91. end
  92. end
  93. def mark(quand)
  94. doc = Nokogiri::HTML(@b.html)
  95. balance = doc.search('//*[@id="VCP_visitorTOTAL_REWARD"]').text
  96. current_addr = doc.search('//*[@id="VCP_visitorADDRESS"]').text
  97. puts quand << " - " << @proxy << " - " << current_addr << " - " << balance
  98. end
  99. def process
  100. sleep(20)
  101. mark("begin")
  102. while check_visit?
  103. Watir::Wait.until(aleat) {
  104. text = @b.text
  105. text.include? "Siguiente URL" or text.include? "Next URL"
  106. }
  107. wait_next
  108. end
  109. mark("end")
  110. end
  111. =begin rdoc
  112. In order to create a valid harvester instance pass btc address.
  113. =end
  114. private
  115. def make_agent(proxy_tested)
  116. proxy_addr, proxy_port = proxy_tested.split(':')
  117. profile = Selenium::WebDriver::Firefox::Profile.new
  118. profile["network.proxy.type"] = 1
  119. profile["network.proxy.http"] = proxy_addr
  120. profile["network.proxy.http_port"] = proxy_port.to_i
  121. @b = Watir::Browser.new :firefox, :profile => profile
  122. end
  123. def kill_agent
  124. @b.close
  125. end
  126. end
  127. end

comments powered by Disqus