Skip to content

Instantly share code, notes, and snippets.

@tempredirect
Created January 15, 2011 23:55
Show Gist options
  • Save tempredirect/781384 to your computer and use it in GitHub Desktop.
Save tempredirect/781384 to your computer and use it in GitHub Desktop.
scrap all the symbols and prices from the LSE website
require 'rubygems'
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://www.londonstockexchange.com/exchange/prices-and-markets/stocks/prices-search/stock-prices-search.html'))
while(true)
doc.css('table.table_dati tbody tr').each do |row|
cells = row.css('td')
values = cells[0..5].map { |cell| cell.content.strip }
values[0] = values[0] + '.L'
puts values.join(',')
end
paging_link = doc.css('div.paging a[title=Next]')[0].attr('href')
break if paging_link == nil
doc = Nokogiri::HTML(open("http://www.londonstockexchange.com#{paging_link}"))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment