Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # http://deathsnacks.com/wf/index.html
- require "open-uri"
- # start new thread
- t = Thread.new do
- # infinite loop
- while true
- # read the content of the webpage
- conn = open('http://deathsnacks.com/wf/index.html').read
- # put in table_data the content of all <li> </li> tags, in this type of tags are the data stored that we need
- table_data = conn.scan /<li.+?li>/
- # we declare another table for refined data and we make it empty
- table_data_refined = []
- # put in table_data_refined the information from table_data that is striped from html tags (the li tags to be more precise)
- table_data.each { |data|
- data.gsub!(/<.+?>/, '')
- # add space after price
- data.gsub!('0cr', '0cr ')
- table_data_refined << data
- }
- puts ' '
- puts ' Warframe Alerts by Neumann Gregor'
- # define a counter and initiate it with 0
- $i = 0
- # for each info in table_data_refined
- table_data_refined.each do |looped|
- # check if the first character of the current record is a number (relevant data for use is with numbers)
- if (table_data_refined[$i][0] =~ /[[:digit:]]/)
- # if yes then display it in a formatted way and with html tags striped, the li tags are replaced with a single space
- puts ' ' + (table_data_refined[$i]).to_s.gsub(/(?<=[a-z])(?=[A-Z])/, ' ')
- end
- # increment counter for the next record
- $i +=1
- end
- # we reread the data and display it every 10 seconds
- sleep 10
- # clear screen, works on windows or linux
- Gem.win_platform? ? (system "cls") : (system "clear")
- end
- end
- #hit enter to exit by killing thread
- gets
- #end thread
- t.kill
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement