-
-
Save nkwsy/30ae6ea95119eb8ed1a4 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 'rubygems' | |
require 'nokogiri' | |
require 'csv' | |
require 'Mechanize' | |
require 'open-uri' | |
#require 'open-uri' | |
agent = Mechanize.new | |
agent.user_agent_alias = 'Mac Safari' | |
page = agent.get('https://relivent.web.page') | |
ticket_form = page.form('enterTicketsForm') | |
ticket_form.ticket1 = 9189531900 | |
ticket_form.ticket2 = 9189531901 | |
page = agent.submit(ticket_form) | |
doc = Nokogiri::HTML(page) | |
csv = CSV.open("xtick.csv", 'w',{:col_sep => ",", :quote_char => '\'', :force_quotes => false, :skip_blanks => true, skip_lines: /^(?:,\s*)+$/}) | |
doc.xpath('//table/tbody/tr').each do |row| | |
tarray = [] | |
row.xpath('td[@class="bodytextsmall"]').each do |cell| | |
tarray << cells.text.strip | |
end | |
puts tarray | |
csv << tarray | |
end | |
csv.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment