Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updates to work with different alert signals

  • Loading branch information...
commit 25857afddb5cd8aa57a4b63a000a8c9225656db4 1 parent 63474c0
@suttree authored
Showing with 15 additions and 14 deletions.
  1. +15 −14 traintimes.rb
View
29 traintimes.rb
@@ -49,23 +49,24 @@
# Digest the page and DM me the details
open(url) do |page|
- page_content = page.read()
- soup = BeautifulSoup.new(page_content)
- result = soup.find('a', :attrs => {'class' => 'status'}).parent
- result = [] if result.nil?
- result.each do |tag|
- tag = tag.to_s
- if tag.include?(time[0].to_s)
- next if tag.include?('changes')
+ @page_content = page.read()
+ end
+
+ soup = BeautifulSoup.new(@page_content)
+ result = soup.find('a', :attrs => {'class' => 'status'}).parent rescue []
+ result.each do |tag|
+ tag = tag.to_s
+ if tag.include?(time[0].to_s)
+ next if tag.include?('changes')
- status_text = soup.find('a', :attrs => {'class' => 'status'}).to_s.gsub(/<\/?[^>]*>/, '')
- dm = tag.to_s.gsub(/<\/?[^>]*>/, '').gsub('%ndash', '-').gsub(/[\t|\n]/,'').split('iCal')[0].chop + " *#{status_text}* " + " ~ #{info}"
- dm = dm.gsub(/\s+/, ' ')
- puts "Sending dm: #{dm}..."
- twitter.direct_message_create('suttree', dm)
- end
+ status_text = soup.find('a', :attrs => {'class' => 'status'}).to_s.gsub(/<\/?[^>]*>/, '')
+ dm = tag.to_s.gsub(/<\/?[^>]*>/, '').gsub('%ndash', '-').gsub(/[\t|\n]/,'').split('iCal')[0].chop + " *#{status_text}* " + " ~ #{info}"
+ dm = dm.gsub(/\s+/, ' ')
+ puts "Sending dm: #{dm}..."
+ twitter.direct_message_create('suttree', dm)
end
end
+ puts @page_content.inspect
end
end
else
Please sign in to comment.
Something went wrong with that request. Please try again.