Skip to content

Instantly share code, notes, and snippets.

@quave
Last active March 23, 2017 14:46
Show Gist options
  • Select an option

  • Save quave/ea01a4fc7341cba89670165057af7f0e to your computer and use it in GitHub Desktop.

Select an option

Save quave/ea01a4fc7341cba89670165057af7f0e to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'nokogiri'
require 'net/http'
require 'json'
l_doc = Nokogiri::HTML(open('https://www.producthunt.com/posts/statsbot-goals'))
p_doc = Nokogiri::HTML(open('https://www.producthunt.com/'))
divs = p_doc.css('.postsList_3n2Ck li').take_while do |div|
puts div.css('.title_24w6f').text
div.css('.title_24w6f').text != 'Statsbot Goals'
end
msg = "Statsbot is on #{divs.count + 1} place with PH Loices #{l_doc.css('.count_3O7GY').text}"
puts msg
begin
uri = URI('<your_slack_webhook>') # Google for Slack Incoming Webhook
res = Net::HTTP.post_form(uri, {payload: '{"channel":"#random", "text":"' + msg + '"}' })
puts "response #{res.body}"
rescue e
puts "failed #{e}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment