Created
August 17, 2015 14:45
-
-
Save kakawka/15944bdfafb7d2614af9 to your computer and use it in GitHub Desktop.
This file contains 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 'telegram/bot' | |
require 'net/http' | |
require 'nokogiri' | |
token = 'блах' | |
last_message_text = 'https://www.upwork.com/jobs/Deploy-Ruby-Rails-app-VPS_%7E011db7752412caefe9?source=rss' | |
100500.times do | |
uri = URI('https://www.upwork.com/find-work-home/rss?securityToken=6f8fb3697e4e8bbbf6e67c9fc0d46985e7a45a64fadb71642916ef53e6620f9c~4818447') | |
xml_str = Net::HTTP.get_response(uri) | |
uri = URI("https://www.upwork.com#{xml_str.to_hash['location'][0]}") | |
xml_str = Net::HTTP.get_response(uri) | |
@doc = Nokogiri::XML(xml_str.body) | |
items = [] | |
item = @doc.css("item").reverse | |
Telegram::Bot::Client.run(token) do |bot| | |
unless last_message_text == item.css('link').last.inner_text | |
item.each_with_index do |i, index| | |
next if i.css('link').inner_text != last_message_text | |
last_message = bot.api.sendMessage(chat_id: 66990400, text: "#{i.css('link').inner_text}") | |
last_message_text = last_message["result"]["text"] | |
end | |
else | |
bot.api.sendMessage(chat_id: 66990400, text: "ничего нового") | |
end | |
end | |
sleep 300 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment