Last active
March 23, 2017 14:46
-
-
Save quave/ea01a4fc7341cba89670165057af7f0e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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