Created
November 4, 2012 05:32
-
-
Save bash0C7/4010438 to your computer and use it in GitHub Desktop.
scrape(Webrat)
This file contains hidden or 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
# -*- 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