Skip to content

Commit

Permalink
using fucking selenium
Browse files Browse the repository at this point in the history
  • Loading branch information
apsheronets committed Jul 5, 2014
1 parent 7ee4526 commit 3b374f1
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions get-bitfinex-sentiment-index.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
require 'mechanize'

agent = Mechanize.new { |agent|
agent.history.max_size=1
agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
}
#agent = Mechanize.new { |agent|
# agent.history.max_size=1
# agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
# }
#
#url = 'https://www.bitfinex.com/pages/stats'
#
#page = agent.get url

url = 'https://www.bitfinex.com/pages/stats'
# Fucking bitfinex added Web3.99 shit-tastic JS-based SaaS DoS-protection
# using fucking selenium
# it's 2014 and I couldn't just download fucking HTML
# holy fuck

page = agent.get url
require 'rubygems'
require 'selenium-webdriver'

driver = Selenium::WebDriver.for :firefox
driver.get "https://www.bitfinex.com/pages/stats"

page = Nokogiri::HTML(driver.page_source)

driver.quit

green = page.root.search('div[@class="progress large-12 success radius"]/span').first.attributes['style'].value.match(/width:\s*([0-9.]+)%/)[1].to_f
red = page.root.search('div[@class="progress large-12 red secondary radius"]/span').first.attributes['style'].value.match(/width:\s*([0-9.]+)%/)[1].to_f
Expand Down

0 comments on commit 3b374f1

Please sign in to comment.