Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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