Skip to content

Instantly share code, notes, and snippets.

@bash0C7
Created November 4, 2012 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bash0C7/4010438 to your computer and use it in GitHub Desktop.
Save bash0C7/4010438 to your computer and use it in GitHub Desktop.
scrape(Webrat)
# -*- coding: utf-8 -*-
require 'mechanize'
require 'webrat'
require 'pry'
Webrat.configure do |config|
config.mode = :mechanize
end
include Webrat::Methods
puts mid
visit_response = visit "http://detail/?mid=#{mid}"
table = visit_response.at('*').children.last.children[19]
puts request_id = table.children.first.children[2].children.first.children.first.text
puts request_date = table.children.first.children[6].children.first.text
puts request_crew = table.children[1].children[2].children.first.text
puts request_title = table.children[3].children[2].children.first.text
puts request_content = table.children[4].children[2].children.select{|e| e.is_a? Nokogiri::XML::Text}.map{|e| e.text.sub(/\r\n/, '')}.join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment