Guest User

Warframe Alerts By Neumann Gregor 2016

a guest
Mar 16th, 2016
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # http://deathsnacks.com/wf/index.html
  2. require "open-uri"
  3. # start new thread
  4. t = Thread.new do
  5. # infinite loop
  6. while true
  7.   # read the content of the webpage
  8.   conn = open('http://deathsnacks.com/wf/index.html').read
  9.   # put in table_data the content of all <li> </li> tags, in this type of tags are the data stored that we need
  10.   table_data = conn.scan /<li.+?li>/
  11.   # we declare another table for refined data and we make it empty
  12.   table_data_refined = []
  13.   # put in table_data_refined the information from table_data that is striped from html tags (the li tags to be more precise)
  14.   table_data.each { |data|
  15.     data.gsub!(/<.+?>/, '')
  16.     # add space after price
  17.     data.gsub!('0cr', '0cr ')
  18.     table_data_refined << data
  19.   }
  20.   puts ' '
  21.   puts ' Warframe Alerts by Neumann Gregor'
  22.   # define a counter and initiate it with 0
  23.   $i = 0
  24.   # for each info in table_data_refined
  25.   table_data_refined.each do |looped|
  26.   # check if the first character of the current record is a number (relevant data for use is with numbers)
  27.   if (table_data_refined[$i][0] =~ /[[:digit:]]/)
  28.     # if yes then display it in a formatted way and with html tags striped, the li tags are replaced with a single space
  29.     puts ' ' + (table_data_refined[$i]).to_s.gsub(/(?<=[a-z])(?=[A-Z])/, ' ')
  30.   end
  31.   # increment counter for the next record
  32.   $i +=1
  33.   end
  34.   # we reread the data and display it every 10 seconds
  35.   sleep 10
  36.   # clear screen, works on windows or linux
  37.   Gem.win_platform? ? (system "cls") : (system "clear")
  38.   end
  39. end
  40. #hit enter to exit by killing thread
  41. gets
  42. #end thread
  43. t.kill
RAW Paste Data